Skip to content

Commit 572aeae

Browse files
committed
Fixed session token naming when passing to Places Details Api New.
Added session token to address validation api request. #413
1 parent 34399b4 commit 572aeae

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

.tests/GoogleApi.Test/PlacesNew/Details/DetailsNewTests.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Linq;
23
using System.Threading.Tasks;
34
using GoogleApi.Entities.Common.Enums;
@@ -17,7 +18,8 @@ public async Task PlacesNewDetailsTest()
1718
var request = new PlacesNewAutoCompleteRequest
1819
{
1920
Key = Settings.ApiKey,
20-
Input = "jagtvej 2200 København"
21+
Input = "jagtvej 2200 København",
22+
SessionToken = Guid.NewGuid().ToString()
2123
};
2224

2325
var response = await GooglePlacesNew.AutoComplete.QueryAsync(request);
@@ -26,7 +28,8 @@ public async Task PlacesNewDetailsTest()
2628
var request2 = new PlacesNewDetailsRequest
2729
{
2830
Key = Settings.ApiKey,
29-
PlaceId = placeId
31+
PlaceId = placeId,
32+
SessionToken = request.SessionToken
3033
};
3134

3235
var result = await GooglePlacesNew.Details.QueryAsync(request2);

GoogleApi/Entities/Maps/AddressValidation/Request/AddressValidationRequest.cs

+9
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,13 @@ public class AddressValidationRequest : BaseMapsRequest, IRequestJson
4343
/// Language Options.
4444
/// </summary>
4545
public virtual LanguageOptions LanguageOptions { get; set; }
46+
47+
/// <summary>
48+
/// Optional.
49+
/// Session tokens are user-generated strings that track Autocomplete (New) calls as "sessions."
50+
/// Autocomplete (New) uses session tokens to group the query and place selection phases of a user autocomplete search into a discrete session for billing purposes.
51+
/// Session tokens are passed into Place Details (New) calls that follow Autocomplete (New) calls. For more information,
52+
/// see https://developers.google.com/maps/documentation/places/web-service/place-session-tokens.
53+
/// </summary>
54+
public virtual string SessionToken { get; set; }
4655
}

GoogleApi/Entities/PlacesNew/Details/Request/PlacesNewDetailsRequest.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using GoogleApi.Entities.Interfaces;
55
using System.Collections.Generic;
66
using System;
7-
using System.Text.Json.Serialization;
87

98
namespace GoogleApi.Entities.PlacesNew.Details.Request;
109

@@ -44,7 +43,6 @@ public class PlacesNewDetailsRequest : BasePlacesNewRequest, IRequestQueryString
4443
/// * The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another.
4544
/// Current list of supported languages: https://developers.google.com/maps/faq#languagesupport.
4645
/// </summary>
47-
[JsonPropertyName("languageCode")]
4846
public virtual Language Language { get; set; } = Language.English;
4947

5048
/// <summary>
@@ -58,7 +56,6 @@ public class PlacesNewDetailsRequest : BasePlacesNewRequest, IRequestQueryString
5856
/// while its ISO 3166-1 code is "gb" (technically for the entity of "The United Kingdom of Great Britain and Northern Ireland").
5957
/// The parameter can affect results based on applicable law.
6058
/// </summary>
61-
[JsonPropertyName("regionCode")]
6259
public virtual string Region { get; set; }
6360

6461
/// <summary>
@@ -92,7 +89,7 @@ public override IList<KeyValuePair<string, string>> GetQueryStringParameters()
9289
if (!string.IsNullOrEmpty(this.SessionToken))
9390
{
9491
parameters
95-
.Add("sessiontoken", this.SessionToken);
92+
.Add("sessionToken", this.SessionToken);
9693
}
9794

9895
return parameters;

GoogleApi/GoogleApi.csproj

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<NoWarn />
77
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
88
<PlatformTarget>AnyCPU</PlatformTarget>
9-
<AssemblyVersion>5.8.3.0</AssemblyVersion>
10-
<FileVersion>5.8.3.0</FileVersion>
11-
<Version>5.8.3.0</Version>
9+
<AssemblyVersion>5.8.4.0</AssemblyVersion>
10+
<FileVersion>5.8.4.0</FileVersion>
11+
<Version>5.8.4.0</Version>
1212
<SignAssembly>True</SignAssembly>
1313
<AssemblyOriginatorKeyFile>GoogleApi.snk</AssemblyOriginatorKeyFile>
1414
<LangVersion>latest</LangVersion>
@@ -22,7 +22,8 @@
2222
<PackageTags>google api map maps place places elevation snaptoroad snaptoroads snap road roads speed speedlimit coordinate geo geocode geocoder geocoding geolocation search text nearby radar translate translation detect detection language languages nearest geography point geocoordinate address location latitude longitude distance duration matrix distancematrix direction directions travel path journey trip photo photos timezone time zone autocomplete auto-complete traffic spatial</PackageTags>
2323
<PackageReadmeFile>README.md</PackageReadmeFile>
2424
<PackageReleaseNotes>
25-
- Added Request.Referer to restrict the domain of the api-key.
25+
- Fixed session token naming when passing to Places Details Api New.
26+
- Added session token to address validation api request.
2627
</PackageReleaseNotes>
2728
<PackageLicenseFile>LICENSE</PackageLicenseFile>
2829
<RepositoryType>GitHub</RepositoryType>

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 5.8.2.{build}
1+
version: 5.8.4.{build}
22
skip_tags: true
33
max_jobs: 1
44
image: Visual Studio 2022

0 commit comments

Comments
 (0)