Skip to content

Commit 12f5a42

Browse files
authored
Merge pull request #493 from mapbox/geocoding-sessionid
Add session_token to Geocoding services
2 parents 41c7da5 + 0e19cc9 commit 12f5a42

File tree

7 files changed

+45
-15
lines changed

7 files changed

+45
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.16.1
4+
5+
- **Add:** Add `session_token` as optional parameter in the geocoding services
6+
37
## 0.16.0
48

59
- **Add:** Add `depart_at` as optional parameter in the isochrone service

docs/services.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,7 @@ See the [public documentation][241].
16871687
* `config.routing` **[boolean][209]** Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features. (optional, default `false`)
16881688
* `config.fuzzyMatch` **[boolean][209]** Specify whether the Geocoding API should attempt approximate, as well as exact, matching. (optional, default `true`)
16891689
* `config.worldview` **[String][208]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`)
1690+
* `config.session_token` **[String][208]?** A unique session identifier generated by the client.
16901691

16911692
#### Examples
16921693

@@ -1758,6 +1759,7 @@ See the [public documentation][245].
17581759
* `config.reverseMode` **(`"distance"` | `"score"`)** Set the factors that are used to sort nearby results. (optional, default `'distance'`)
17591760
* `config.routing` **[boolean][209]** Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features. (optional, default `false`)
17601761
* `config.worldview` **[String][208]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`)
1762+
* `config.session_token` **[String][208]?** A unique session identifier generated by the client.
17611763

17621764
#### Examples
17631765

@@ -2380,6 +2382,7 @@ See the [public documentation][264].
23802382
* `config.autocomplete` **[boolean][209]** Return autocomplete results or not. (optional, default `true`)
23812383
* `config.permanent` **[boolean][209]** Specify whether you intend to store the results of the query (true) or not (false, default). Temporary results are not allowed to be cached, while Permanent results are allowed to be cached and stored indefinitely. (optional, default `false`)
23822384
* `config.worldview` **[String][208]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`)
2385+
* `config.session_token` **[String][208]?** A unique session identifier generated by the client.
23832386

23842387
#### Examples
23852388

@@ -2463,6 +2466,7 @@ See the [public documentation][265].
24632466
[ISO 639-1 language code][244] and optionally one or more IETF subtags for country or script.
24642467
* `config.permanent` **[boolean][209]** Specify whether you intend to store the results of the query (true) or not (false, default). Temporary results are not allowed to be cached, while Permanent results are allowed to be cached and stored indefinitely. (optional, default `false`)
24652468
* `config.worldview` **[String][208]** Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups. (optional, default `"us"`)
2469+
* `config.session_token` **[String][208]?** A unique session identifier generated by the client.
24662470

24672471
#### Examples
24682472

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mapbox/mapbox-sdk",
3-
"version": "0.16.0",
3+
"version": "0.16.1",
44
"description": "JS SDK for accessing Mapbox APIs",
55
"main": "index.js",
66
"files": [

services/__tests__/geocoding-v6.test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe('forwardGeocode', () => {
3434
language: 'de',
3535
worldview: 'us',
3636
permanent: true,
37+
session_token: 'abc123',
3738

3839
// structured input parameters will be ignored in normal mode
3940
address_line1: '12 main',
@@ -60,7 +61,8 @@ describe('forwardGeocode', () => {
6061
limit: 3,
6162
language: 'de',
6263
worldview: 'us',
63-
permanent: 'true'
64+
permanent: 'true',
65+
session_token: 'abc123'
6466
}
6567
});
6668
});
@@ -76,6 +78,7 @@ describe('forwardGeocode', () => {
7678
limit: 3,
7779
language: 'de',
7880
worldview: 'us',
81+
session_token: 'abc123',
7982

8083
// structured input parameters will be picked
8184
address_line1: '12 main',
@@ -99,6 +102,7 @@ describe('forwardGeocode', () => {
99102
limit: 3,
100103
language: 'de',
101104
worldview: 'us',
105+
session_token: 'abc123',
102106

103107
address_line1: '12 main',
104108
address_number: '12',
@@ -140,7 +144,8 @@ describe('reverseGeocode', () => {
140144
limit: 3,
141145
language: 'de',
142146
worldview: 'us',
143-
permanent: true
147+
permanent: true,
148+
session_token: 'abc123'
144149
});
145150
expect(tu.requestConfig(geocoding)).toEqual({
146151
method: 'GET',
@@ -153,7 +158,8 @@ describe('reverseGeocode', () => {
153158
limit: 3,
154159
language: 'de',
155160
worldview: 'us',
156-
permanent: 'true'
161+
permanent: 'true',
162+
session_token: 'abc123'
157163
}
158164
});
159165
});

services/__tests__/geocoding.test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ describe('forwardGeocode', () => {
3737
language: ['de', 'bs'],
3838
routing: true,
3939
fuzzyMatch: true,
40-
worldview: 'us'
40+
worldview: 'us',
41+
session_token: 'abc123'
4142
});
4243
expect(tu.requestConfig(geocoding)).toEqual({
4344
method: 'GET',
@@ -56,7 +57,8 @@ describe('forwardGeocode', () => {
5657
language: ['de', 'bs'],
5758
routing: 'true',
5859
fuzzyMatch: 'true',
59-
worldview: 'us'
60+
worldview: 'us',
61+
session_token: 'abc123'
6062
}
6163
});
6264
});
@@ -89,7 +91,8 @@ describe('reverseGeocode', () => {
8991
language: ['de', 'bs'],
9092
reverseMode: 'distance',
9193
routing: true,
92-
worldview: 'us'
94+
worldview: 'us',
95+
session_token: 'abc123'
9396
});
9497
expect(tu.requestConfig(geocoding)).toEqual({
9598
method: 'GET',
@@ -106,7 +109,8 @@ describe('reverseGeocode', () => {
106109
language: ['de', 'bs'],
107110
reverseMode: 'distance',
108111
routing: 'true',
109-
worldview: 'us'
112+
worldview: 'us',
113+
session_token: 'abc123'
110114
}
111115
});
112116
});

services/geocoding-v6.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var featureTypes = [
5858
* @param {boolean} [config.autocomplete=true] - Return autocomplete results or not.
5959
* @param {boolean} [config.permanent=false] - Specify whether you intend to store the results of the query (true) or not (false, default). Temporary results are not allowed to be cached, while Permanent results are allowed to be cached and stored indefinitely.
6060
* @param {String} [config.worldview="us"] - Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups.
61+
* @param {String} [config.session_token] - A unique session identifier generated by the client.
6162
* @return {MapiRequest}
6263
*
6364
* @example
@@ -129,6 +130,7 @@ GeocodingV6.forwardGeocode = function(config) {
129130
worldview: v.string,
130131
autocomplete: v.boolean,
131132
permanent: v.boolean,
133+
session_token: v.string,
132134

133135
// structured input fields
134136
address_line1: v.string,
@@ -168,7 +170,8 @@ GeocodingV6.forwardGeocode = function(config) {
168170
'limit',
169171
'worldview',
170172
'autocomplete',
171-
'permanent'
173+
'permanent',
174+
'session_token'
172175
])
173176
)
174177
);
@@ -198,6 +201,7 @@ GeocodingV6.forwardGeocode = function(config) {
198201
* [ISO 639-1 language code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) and optionally one or more IETF subtags for country or script.
199202
* @param {boolean} [config.permanent=false] - Specify whether you intend to store the results of the query (true) or not (false, default). Temporary results are not allowed to be cached, while Permanent results are allowed to be cached and stored indefinitely.
200203
* @param {String} [config.worldview="us"] - Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups.
204+
* @param {String} [config.session_token] - A unique session identifier generated by the client.
201205
* @return {MapiRequest}
202206
*
203207
* @example
@@ -220,7 +224,8 @@ GeocodingV6.reverseGeocode = function(config) {
220224
limit: v.number,
221225
language: v.string,
222226
worldview: v.string,
223-
permanent: v.boolean
227+
permanent: v.boolean,
228+
session_token: v.string
224229
})(config);
225230

226231
var query = stringifyBooleans(
@@ -233,7 +238,8 @@ GeocodingV6.reverseGeocode = function(config) {
233238
'limit',
234239
'language',
235240
'worldview',
236-
'permanent'
241+
'permanent',
242+
'session_token'
237243
])
238244
)
239245
);

services/geocoding.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ var featureTypes = [
4848
* @param {boolean} [config.routing=false] - Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features.
4949
* @param {boolean} [config.fuzzyMatch=true] - Specify whether the Geocoding API should attempt approximate, as well as exact, matching.
5050
* @param {String} [config.worldview="us"] - Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups.
51+
* @param {String} [config.session_token] - A unique session identifier generated by the client.
5152
* @return {MapiRequest}
5253
*
5354
* @example
@@ -104,7 +105,8 @@ Geocoding.forwardGeocode = function(config) {
104105
language: v.arrayOf(v.string),
105106
routing: v.boolean,
106107
fuzzyMatch: v.boolean,
107-
worldview: v.string
108+
worldview: v.string,
109+
session_token: v.string
108110
})(config);
109111

110112
config.mode = config.mode || 'mapbox.places';
@@ -121,7 +123,8 @@ Geocoding.forwardGeocode = function(config) {
121123
'language',
122124
'routing',
123125
'fuzzyMatch',
124-
'worldview'
126+
'worldview',
127+
'session_token'
125128
])
126129
)
127130
);
@@ -153,6 +156,7 @@ Geocoding.forwardGeocode = function(config) {
153156
* @param {'distance'|'score'} [config.reverseMode='distance'] - Set the factors that are used to sort nearby results.
154157
* @param {boolean} [config.routing=false] - Specify whether to request additional metadata about the recommended navigation destination. Only applicable for address features.
155158
* @param {String} [config.worldview="us"] - Filter results to geographic features whose characteristics are defined differently by audiences belonging to various regional, cultural, or political groups.
159+
* @param {String} [config.session_token] - A unique session identifier generated by the client.
156160
* @return {MapiRequest}
157161
*
158162
* @example
@@ -176,7 +180,8 @@ Geocoding.reverseGeocode = function(config) {
176180
language: v.arrayOf(v.string),
177181
reverseMode: v.oneOf('distance', 'score'),
178182
routing: v.boolean,
179-
worldview: v.string
183+
worldview: v.string,
184+
session_token: v.string
180185
})(config);
181186

182187
config.mode = config.mode || 'mapbox.places';
@@ -192,7 +197,8 @@ Geocoding.reverseGeocode = function(config) {
192197
'language',
193198
'reverseMode',
194199
'routing',
195-
'worldview'
200+
'worldview',
201+
'session_token'
196202
])
197203
)
198204
);

0 commit comments

Comments
 (0)