Skip to content

Commit a7231e0

Browse files
feat: [google-maps-addressvalidation] add session token support for Autocomplete (New) sessions that end with a call to Address Validation (#12331)
BEGIN_COMMIT_OVERRIDE feat: add session token support for Autocomplete (New) sessions that end with a call to Address Validation feat: add new fields to USPS data docs: update proto field descriptions END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. feat: add new fields to USPS data docs: update proto field descriptions PiperOrigin-RevId: 608369029 Source-Link: googleapis/googleapis@5ff3e52 Source-Link: googleapis/googleapis-gen@c182835 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLW1hcHMtYWRkcmVzc3ZhbGlkYXRpb24vLk93bEJvdC55YW1sIiwiaCI6ImMxODI4MzU4YmU0MTJiYTAyZTQ1YmZiYWUzYWZjMmIzZGFkZDVkMzIifQ== --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: ohmayr <[email protected]>
1 parent 9379366 commit a7231e0

File tree

4 files changed

+179
-17
lines changed

4 files changed

+179
-17
lines changed

packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/types/address.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,13 @@ class AddressComponent(proto.Message):
138138
location and believe it should be provided for a
139139
complete address.
140140
spell_corrected (bool):
141-
Indicates the spelling of the component name
142-
was corrected in a minor way, for example by
143-
switching two characters that appeared in the
144-
wrong order. This indicates a cosmetic change.
141+
Indicates a correction to a misspelling in
142+
the component name. The API does not always
143+
flag changes from one spelling variant to
144+
another, such as when changing "centre" to
145+
"center". It also does not always flag common
146+
misspellings, such as when changing
147+
"Amphitheater Pkwy" to "Amphitheatre Pkwy".
145148
replaced (bool):
146149
Indicates the name of the component was
147150
replaced with a completely different one, for

packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/types/address_validation_service.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class ValidateAddressRequest(proto.Message):
5050
The total length of the fields in this input must not exceed
5151
280 characters.
5252
53-
Supported regions can be found in the
54-
`FAQ <https://developers.google.com/maps/documentation/address-validation/faq#which_regions_are_currently_supported>`__.
53+
Supported regions can be found
54+
`here <https://developers.google.com/maps/documentation/address-validation/coverage>`__.
5555
5656
The [language_code][google.type.PostalAddress.language_code]
5757
value in the input address is reserved for future uses and
@@ -89,6 +89,30 @@ class ValidateAddressRequest(proto.Message):
8989
[google.type.PostalAddress.address_lines] where the first
9090
line contains the street number and name and the second line
9191
contains the city, state, and zip code.
92+
session_token (str):
93+
Optional. A string which identifies an Autocomplete session
94+
for billing purposes. Must be a URL and filename safe base64
95+
string with at most 36 ASCII characters in length. Otherwise
96+
an INVALID_ARGUMENT error is returned.
97+
98+
The session begins when the user starts typing a query, and
99+
concludes when they select a place and a call to Place
100+
Details or Address Validation is made. Each session can have
101+
multiple autocomplete queries, followed by one Place Details
102+
or Address Validation request. The credentials used for each
103+
request within a session must belong to the same Google
104+
Cloud Console project. Once a session has concluded, the
105+
token is no longer valid; your app must generate a fresh
106+
token for each session. If the ``session_token`` parameter
107+
is omitted, or if you reuse a session token, the session is
108+
charged as if no session token was provided (each request is
109+
billed separately).
110+
111+
Note: Address Validation can only be used in sessions with
112+
the Autocomplete (New) API, not the old Autocomplete API.
113+
See
114+
https://developers.google.com/maps/documentation/places/web-service/session-pricing
115+
for more details.
92116
"""
93117

94118
address: postal_address_pb2.PostalAddress = proto.Field(
@@ -104,6 +128,10 @@ class ValidateAddressRequest(proto.Message):
104128
proto.BOOL,
105129
number=3,
106130
)
131+
session_token: str = proto.Field(
132+
proto.STRING,
133+
number=5,
134+
)
107135

108136

109137
class ValidateAddressResponse(proto.Message):
@@ -329,7 +357,7 @@ class Granularity(proto.Enum):
329357
PREMISE (2):
330358
Building-level result.
331359
PREMISE_PROXIMITY (3):
332-
A geocode that should be very close to the
360+
A geocode that approximates the
333361
building-level location of the address.
334362
BLOCK (4):
335363
The address or geocode indicates a block.

packages/google-maps-addressvalidation/google/maps/addressvalidation_v1/types/usps_data.py

Lines changed: 140 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,30 +110,33 @@ class UspsData(proto.Message):
110110
should yield a number divisible by 10.
111111
dpv_confirmation (str):
112112
The possible values for DPV confirmation. Returns a single
113-
character.
113+
character or returns no value.
114114
115-
- ``Y``: Address was DPV confirmed for primary and any
116-
secondary numbers.
117115
- ``N``: Primary and any secondary number information
118116
failed to DPV confirm.
119-
- ``S``: Address was DPV confirmed for the primary number
120-
only, and the secondary number information was present by
121-
not confirmed.
122117
- ``D``: Address was DPV confirmed for the primary number
123118
only, and the secondary number information was missing.
119+
- ``S``: Address was DPV confirmed for the primary number
120+
only, and the secondary number information was present
121+
but not confirmed.
122+
- ``Y``: Address was DPV confirmed for primary and any
123+
secondary numbers.
124+
- Empty: If the response does not contain a
125+
``dpv_confirmation`` value, the address was not submitted
126+
for DPV confirmation.
124127
dpv_footnote (str):
125128
The footnotes from delivery point validation. Multiple
126129
footnotes may be strung together in the same string.
127130
128131
- ``AA``: Input address matched to the ZIP+4 file
129132
- ``A1``: Input address was not matched to the ZIP+4 file
130133
- ``BB``: Matched to DPV (all components)
131-
- ``CC``: Secondary number not matched (present but
132-
invalid)
134+
- ``CC``: Secondary number not matched and not required
135+
- ``C1``: Secondary number not matched but required
133136
- ``N1``: High-rise address missing secondary number
134137
- ``M1``: Primary number missing
135138
- ``M3``: Primary number invalid
136-
- ``P1``: Input address RR or HC box number missing
139+
- ``P1``: Input address PO, RR or HC box number missing
137140
- ``P3``: Input address PO, RR, or HC Box number invalid
138141
- ``F1``: Input address matched to a military address
139142
- ``G1``: Input address matched to a general delivery
@@ -143,6 +146,9 @@ class UspsData(proto.Message):
143146
- ``RR``: DPV confirmed address with PMB information
144147
- ``R1``: DPV confirmed address without PMB information
145148
- ``R7``: Carrier Route R777 or R779 record
149+
- ``IA``: Informed Address identified
150+
- ``TA``: Primary number matched by dropping a trailing
151+
alpha
146152
dpv_cmra (str):
147153
Indicates if the address is a CMRA (Commercial Mail
148154
Receiving Agency)--a private business receiving mail for
@@ -163,6 +169,95 @@ class UspsData(proto.Message):
163169
164170
- ``Y``: The address is not active
165171
- ``N``: The address is active
172+
dpv_no_stat_reason_code (int):
173+
Indicates the NoStat type. Returns a reason code as int.
174+
175+
- ``1``: IDA (Internal Drop Address) – Addresses that do
176+
not receive mail directly from the USPS but are delivered
177+
to a drop address that services them.
178+
- ``2``: CDS - Addresses that have not yet become
179+
deliverable. For example, a new subdivision where lots
180+
and primary numbers have been determined, but no
181+
structure exists yet for occupancy.
182+
- ``3``: Collision - Addresses that do not actually DPV
183+
confirm.
184+
- ``4``: CMZ (College, Military and Other Types) - ZIP + 4
185+
records USPS has incorporated into the data.
186+
- ``5``: Regular - Indicates addresses not receiving
187+
delivery and the addresses are not counted as possible
188+
deliveries.
189+
- ``6``: Secondary Required - The address requires
190+
secondary information.
191+
dpv_drop (str):
192+
Flag indicates mail is delivered to a single receptable at a
193+
site. Returns a single character.
194+
195+
- ``Y``: The mail is delivered to a single receptable at a
196+
site.
197+
- ``N``: The mail is not delivered to a single receptable
198+
at a site.
199+
dpv_throwback (str):
200+
Indicates that mail is not delivered to the street address.
201+
Returns a single character.
202+
203+
- ``Y``: The mail is not delivered to the street address.
204+
- ``N``: The mail is delivered to the street address.
205+
dpv_non_delivery_days (str):
206+
Flag indicates mail delivery is not performed every day of
207+
the week. Returns a single character.
208+
209+
- ``Y``: The mail delivery is not performed every day of
210+
the week.
211+
- ``N``: No indication the mail delivery is not performed
212+
every day of the week.
213+
dpv_non_delivery_days_values (int):
214+
Integer identifying non-delivery days. It can
215+
be interrogated using bit flags:
216+
217+
0x40 – Sunday is a non-delivery day
218+
0x20 – Monday is a non-delivery day
219+
0x10 – Tuesday is a non-delivery day
220+
0x08 – Wednesday is a non-delivery day
221+
0x04 – Thursday is a non-delivery day
222+
0x02 – Friday is a non-delivery day
223+
0x01 – Saturday is a non-delivery day
224+
dpv_no_secure_location (str):
225+
Flag indicates door is accessible, but package will not be
226+
left due to security concerns. Returns a single character.
227+
228+
- ``Y``: The package will not be left due to security
229+
concerns.
230+
- ``N``: No indication the package will not be left due to
231+
security concerns.
232+
dpv_pbsa (str):
233+
Indicates the address was matched to PBSA record. Returns a
234+
single character.
235+
236+
- ``Y``: The address was matched to PBSA record.
237+
- ``N``: The address was not matched to PBSA record.
238+
dpv_door_not_accessible (str):
239+
Flag indicates addresses where USPS cannot knock on a door
240+
to deliver mail. Returns a single character.
241+
242+
- ``Y``: The door is not accessible.
243+
- ``N``: No indication the door is not accessible.
244+
dpv_enhanced_delivery_code (str):
245+
Indicates that more than one DPV return code is valid for
246+
the address. Returns a single character.
247+
248+
- ``Y``: Address was DPV confirmed for primary and any
249+
secondary numbers.
250+
- ``N``: Primary and any secondary number information
251+
failed to DPV confirm.
252+
- ``S``: Address was DPV confirmed for the primary number
253+
only, and the secondary number information was present by
254+
not confirmed, or a single trailing alpha on a primary
255+
number was dropped to make a DPV match and secondary
256+
information required.
257+
- ``D``: Address was DPV confirmed for the primary number
258+
only, and the secondary number information was missing.
259+
- ``R``: Address confirmed but assigned to phantom route
260+
R777 and R779 and USPS delivery is not provided.
166261
carrier_route (str):
167262
The carrier route code. A four character code consisting of
168263
a one letter prefix and a three digit route designator.
@@ -276,6 +371,42 @@ class UspsData(proto.Message):
276371
proto.STRING,
277372
number=8,
278373
)
374+
dpv_no_stat_reason_code: int = proto.Field(
375+
proto.INT32,
376+
number=29,
377+
)
378+
dpv_drop: str = proto.Field(
379+
proto.STRING,
380+
number=30,
381+
)
382+
dpv_throwback: str = proto.Field(
383+
proto.STRING,
384+
number=31,
385+
)
386+
dpv_non_delivery_days: str = proto.Field(
387+
proto.STRING,
388+
number=32,
389+
)
390+
dpv_non_delivery_days_values: int = proto.Field(
391+
proto.INT32,
392+
number=33,
393+
)
394+
dpv_no_secure_location: str = proto.Field(
395+
proto.STRING,
396+
number=34,
397+
)
398+
dpv_pbsa: str = proto.Field(
399+
proto.STRING,
400+
number=35,
401+
)
402+
dpv_door_not_accessible: str = proto.Field(
403+
proto.STRING,
404+
number=36,
405+
)
406+
dpv_enhanced_delivery_code: str = proto.Field(
407+
proto.STRING,
408+
number=37,
409+
)
279410
carrier_route: str = proto.Field(
280411
proto.STRING,
281412
number=9,

packages/google-maps-addressvalidation/scripts/fixup_addressvalidation_v1_keywords.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class addressvalidationCallTransformer(cst.CSTTransformer):
4040
CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
4141
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
4242
'provide_validation_feedback': ('conclusion', 'response_id', ),
43-
'validate_address': ('address', 'previous_response_id', 'enable_usps_cass', ),
43+
'validate_address': ('address', 'previous_response_id', 'enable_usps_cass', 'session_token', ),
4444
}
4545

4646
def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:

0 commit comments

Comments
 (0)