ideal-postcodes 0.2.2__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ideal_postcodes-0.2.2 → ideal_postcodes-0.3.0}/PKG-INFO +1 -1
- {ideal_postcodes-0.2.2 → ideal_postcodes-0.3.0}/ideal_postcodes/_transport.py +2 -1
- {ideal_postcodes-0.2.2 → ideal_postcodes-0.3.0}/ideal_postcodes/client.py +41 -6
- {ideal_postcodes-0.2.2 → ideal_postcodes-0.3.0}/ideal_postcodes/types.py +10 -10
- {ideal_postcodes-0.2.2 → ideal_postcodes-0.3.0}/pyproject.toml +1 -1
- {ideal_postcodes-0.2.2 → ideal_postcodes-0.3.0}/pyproject.toml.orig +1 -1
- {ideal_postcodes-0.2.2 → ideal_postcodes-0.3.0}/LICENSE +0 -0
- {ideal_postcodes-0.2.2 → ideal_postcodes-0.3.0}/README.md +0 -0
- {ideal_postcodes-0.2.2 → ideal_postcodes-0.3.0}/ideal_postcodes/__init__.py +0 -0
- {ideal_postcodes-0.2.2 → ideal_postcodes-0.3.0}/ideal_postcodes/errors.py +0 -0
- {ideal_postcodes-0.2.2 → ideal_postcodes-0.3.0}/ideal_postcodes/py.typed +0 -0
- {ideal_postcodes-0.2.2 → ideal_postcodes-0.3.0}/ideal_postcodes/requests.py +0 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import platform
|
|
5
6
|
import re
|
|
6
7
|
from collections.abc import Mapping
|
|
7
8
|
from functools import cache
|
|
@@ -15,7 +16,7 @@ from pydantic import TypeAdapter, ValidationError
|
|
|
15
16
|
from .errors import ProtocolError, TransportError, error_for
|
|
16
17
|
|
|
17
18
|
BASE_URL = "https://api.ideal-postcodes.co.uk/v1"
|
|
18
|
-
USER_AGENT = f"ideal-postcodes-python-sdk/{version('ideal-postcodes')}"
|
|
19
|
+
USER_AGENT = f"ideal-postcodes-python-sdk/{version('ideal-postcodes')} python/{platform.python_version()}"
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
def segment(value: str | int) -> str:
|
|
@@ -14,6 +14,7 @@ INPUTS: dict[str, dict[str, Any]] = {
|
|
|
14
14
|
"filter": {"type": "string"},
|
|
15
15
|
"page": {"type": "integer", "minimum": 0, "maximum": 100},
|
|
16
16
|
"tags": {"type": "string"},
|
|
17
|
+
"remove_organisation": {"type": "string"},
|
|
17
18
|
"dataset": {"type": "array", "items": {"type": "string"}},
|
|
18
19
|
"context": {"type": "string"},
|
|
19
20
|
},
|
|
@@ -101,6 +102,7 @@ INPUTS: dict[str, dict[str, Any]] = {
|
|
|
101
102
|
},
|
|
102
103
|
"address_cleanse": {
|
|
103
104
|
"tags": {"type": "string"},
|
|
105
|
+
"remove_organisation": {"type": "string"},
|
|
104
106
|
"context": {"type": "string"},
|
|
105
107
|
"query": {"type": "string"},
|
|
106
108
|
"postcode": {"type": "string"},
|
|
@@ -146,7 +148,11 @@ INPUTS: dict[str, dict[str, Any]] = {
|
|
|
146
148
|
"is_pobox": {"type": "string"},
|
|
147
149
|
"is_business": {"type": "string"},
|
|
148
150
|
},
|
|
149
|
-
"resolve_address": {
|
|
151
|
+
"resolve_address": {
|
|
152
|
+
"address": {"type": "string"},
|
|
153
|
+
"tags": {"type": "string"},
|
|
154
|
+
"remove_organisation": {"type": "string"},
|
|
155
|
+
},
|
|
150
156
|
"addresses": {
|
|
151
157
|
"query": {"type": "string"},
|
|
152
158
|
"limit": {"type": "integer", "minimum": 1, "maximum": 100},
|
|
@@ -173,6 +179,7 @@ INPUTS: dict[str, dict[str, Any]] = {
|
|
|
173
179
|
"bias_country": {"type": "string"},
|
|
174
180
|
"bias_lonlat": {"type": "string"},
|
|
175
181
|
"tags": {"type": "string"},
|
|
182
|
+
"remove_organisation": {"type": "string"},
|
|
176
183
|
"dataset": {"type": "array", "items": {"type": "string"}},
|
|
177
184
|
},
|
|
178
185
|
"find_place": {
|
|
@@ -251,6 +258,7 @@ class IdealPostcodes(Transport):
|
|
|
251
258
|
filter: None = None,
|
|
252
259
|
page: int | None = None,
|
|
253
260
|
tags: str | None = None,
|
|
261
|
+
remove_organisation: Literal["true"] | str | None = None,
|
|
254
262
|
dataset: list[types.Dataset] | None = None,
|
|
255
263
|
context: str | None = None,
|
|
256
264
|
) -> types.PostcodesResult: ...
|
|
@@ -263,6 +271,7 @@ class IdealPostcodes(Transport):
|
|
|
263
271
|
filter: str,
|
|
264
272
|
page: int | None = None,
|
|
265
273
|
tags: str | None = None,
|
|
274
|
+
remove_organisation: Literal["true"] | str | None = None,
|
|
266
275
|
dataset: list[types.Dataset] | None = None,
|
|
267
276
|
context: str | None = None,
|
|
268
277
|
) -> list[dict[str, Any]]: ...
|
|
@@ -274,6 +283,7 @@ class IdealPostcodes(Transport):
|
|
|
274
283
|
filter: str | None = None,
|
|
275
284
|
page: int | None = None,
|
|
276
285
|
tags: str | None = None,
|
|
286
|
+
remove_organisation: Literal["true"] | str | None = None,
|
|
277
287
|
dataset: list[types.Dataset] | None = None,
|
|
278
288
|
context: str | None = None,
|
|
279
289
|
) -> types.PostcodesResult | list[dict[str, Any]]:
|
|
@@ -284,6 +294,7 @@ class IdealPostcodes(Transport):
|
|
|
284
294
|
filter: Optional. Comma separated whitelist of address elements to return.
|
|
285
295
|
page: Optional. 0 indexed indicator of the page of results to receive. Virtually all postcode results are returned on page 0. default=0; minimum=0; maximum=100
|
|
286
296
|
tags: Optional. A comma separated list of tags to query over.
|
|
297
|
+
remove_organisation: Optional. Removes organisation and department names from the address lines (`line_1`, `line_2`, ...). Remaining lines move up. Useful when delivering to people rather than businesses. enum=['true']
|
|
287
298
|
dataset: Optional. Comma-separated list of datasets to search within.
|
|
288
299
|
context: Optional. Limits search results, typically within a country.
|
|
289
300
|
|
|
@@ -295,6 +306,7 @@ class IdealPostcodes(Transport):
|
|
|
295
306
|
filter=filter,
|
|
296
307
|
page=page,
|
|
297
308
|
tags=tags,
|
|
309
|
+
remove_organisation=remove_organisation,
|
|
298
310
|
dataset=dataset,
|
|
299
311
|
context=context,
|
|
300
312
|
)
|
|
@@ -306,7 +318,14 @@ class IdealPostcodes(Transport):
|
|
|
306
318
|
"GET",
|
|
307
319
|
f"/postcodes/{segment(postcode)}",
|
|
308
320
|
result_shape="array",
|
|
309
|
-
query={
|
|
321
|
+
query={
|
|
322
|
+
"filter": filter,
|
|
323
|
+
"page": page,
|
|
324
|
+
"tags": tags,
|
|
325
|
+
"remove_organisation": remove_organisation,
|
|
326
|
+
"dataset": dataset,
|
|
327
|
+
"context": context,
|
|
328
|
+
},
|
|
310
329
|
),
|
|
311
330
|
),
|
|
312
331
|
)
|
|
@@ -488,6 +507,7 @@ class IdealPostcodes(Transport):
|
|
|
488
507
|
*,
|
|
489
508
|
query: str,
|
|
490
509
|
tags: str | None = None,
|
|
510
|
+
remove_organisation: Literal["true"] | str | None = None,
|
|
491
511
|
context: str | None = None,
|
|
492
512
|
postcode: str | None = None,
|
|
493
513
|
post_town: str | None = None,
|
|
@@ -497,6 +517,7 @@ class IdealPostcodes(Transport):
|
|
|
497
517
|
|
|
498
518
|
POST /cleanse/addresses. Returns the result payload.
|
|
499
519
|
tags: Optional. A comma separated list of tags to query over.
|
|
520
|
+
remove_organisation: Optional. Removes organisation and department names from the address lines (`line_1`, `line_2`, ...). Remaining lines move up. Useful when delivering to people rather than businesses. enum=['true']
|
|
500
521
|
context: Optional. Identify the country of the address to cleanse. Defaults to UK (GBR)
|
|
501
522
|
query: Required. Freeform address input to cleanse
|
|
502
523
|
postcode: Optional. Optionally specify the postal code for the address.
|
|
@@ -509,6 +530,7 @@ class IdealPostcodes(Transport):
|
|
|
509
530
|
INPUTS["address_cleanse"],
|
|
510
531
|
query=query,
|
|
511
532
|
tags=tags,
|
|
533
|
+
remove_organisation=remove_organisation,
|
|
512
534
|
context=context,
|
|
513
535
|
postcode=postcode,
|
|
514
536
|
post_town=post_town,
|
|
@@ -521,7 +543,7 @@ class IdealPostcodes(Transport):
|
|
|
521
543
|
self._request(
|
|
522
544
|
"POST",
|
|
523
545
|
"/cleanse/addresses",
|
|
524
|
-
query={"tags": tags, "context": context},
|
|
546
|
+
query={"tags": tags, "remove_organisation": remove_organisation, "context": context},
|
|
525
547
|
body=fields({"query": query, "postcode": postcode, "post_town": post_town, "county": county}),
|
|
526
548
|
),
|
|
527
549
|
),
|
|
@@ -701,21 +723,28 @@ class IdealPostcodes(Transport):
|
|
|
701
723
|
),
|
|
702
724
|
)
|
|
703
725
|
|
|
704
|
-
def resolve_address(
|
|
726
|
+
def resolve_address(
|
|
727
|
+
self, address: str, *, tags: str | None = None, remove_organisation: Literal["true"] | str | None = None
|
|
728
|
+
) -> types.ResolveAddressResult:
|
|
705
729
|
"""Resolve Address.
|
|
706
730
|
|
|
707
731
|
GET /autocomplete/addresses/{address}/gbr. Returns the result payload.
|
|
708
732
|
address: Required. ID of address suggestion provided by the API to fully resolve.
|
|
709
733
|
tags: Optional. A comma separated list of tags to query over.
|
|
734
|
+
remove_organisation: Optional. Removes organisation and department names from the address lines (`line_1`, `line_2`, ...). Remaining lines move up. Useful when delivering to people rather than businesses. enum=['true']
|
|
710
735
|
|
|
711
736
|
Raises APIError, TransportError or ProtocolError on failure.
|
|
712
737
|
"""
|
|
713
|
-
check_inputs(INPUTS["resolve_address"], address=address, tags=tags)
|
|
738
|
+
check_inputs(INPUTS["resolve_address"], address=address, tags=tags, remove_organisation=remove_organisation)
|
|
714
739
|
return cast(
|
|
715
740
|
types.ResolveAddressResult,
|
|
716
741
|
validate(
|
|
717
742
|
types.ResolveAddressResult,
|
|
718
|
-
self._request(
|
|
743
|
+
self._request(
|
|
744
|
+
"GET",
|
|
745
|
+
f"/autocomplete/addresses/{segment(address)}/gbr",
|
|
746
|
+
query={"tags": tags, "remove_organisation": remove_organisation},
|
|
747
|
+
),
|
|
719
748
|
),
|
|
720
749
|
)
|
|
721
750
|
|
|
@@ -748,6 +777,7 @@ class IdealPostcodes(Transport):
|
|
|
748
777
|
bias_country: str | None = None,
|
|
749
778
|
bias_lonlat: str | None = None,
|
|
750
779
|
tags: str | None = None,
|
|
780
|
+
remove_organisation: Literal["true"] | str | None = None,
|
|
751
781
|
dataset: list[types.Dataset] | None = None,
|
|
752
782
|
) -> types.AddressesResult: ...
|
|
753
783
|
|
|
@@ -780,6 +810,7 @@ class IdealPostcodes(Transport):
|
|
|
780
810
|
bias_country: str | None = None,
|
|
781
811
|
bias_lonlat: str | None = None,
|
|
782
812
|
tags: str | None = None,
|
|
813
|
+
remove_organisation: Literal["true"] | str | None = None,
|
|
783
814
|
dataset: list[types.Dataset] | None = None,
|
|
784
815
|
) -> types.ProjectedAddressesResult: ...
|
|
785
816
|
|
|
@@ -811,6 +842,7 @@ class IdealPostcodes(Transport):
|
|
|
811
842
|
bias_country: str | None = None,
|
|
812
843
|
bias_lonlat: str | None = None,
|
|
813
844
|
tags: str | None = None,
|
|
845
|
+
remove_organisation: Literal["true"] | str | None = None,
|
|
814
846
|
dataset: list[types.Dataset] | None = None,
|
|
815
847
|
) -> types.AddressesResult | types.ProjectedAddressesResult:
|
|
816
848
|
"""Extract Addresses.
|
|
@@ -841,6 +873,7 @@ class IdealPostcodes(Transport):
|
|
|
841
873
|
bias_country: Optional. Possible values are England, Scotland, Wales, Northern Ireland, Jersey, Guernsey and Isle of Man.
|
|
842
874
|
bias_lonlat: Optional. Bias search to a geospatial circle determined by an origin and radius in metres. Max radius is `50000`. Uses the format bias_lonlat=[longitude],[latitude],[radius in metres]. Only one geospatial bias may be provided.
|
|
843
875
|
tags: Optional. A comma separated list of tags to query over.
|
|
876
|
+
remove_organisation: Optional. Removes organisation and department names from the address lines (`line_1`, `line_2`, ...). Remaining lines move up. Useful when delivering to people rather than businesses. enum=['true']
|
|
844
877
|
dataset: Optional. Comma-separated list of datasets to search within.
|
|
845
878
|
|
|
846
879
|
Raises APIError, TransportError or ProtocolError on failure.
|
|
@@ -872,6 +905,7 @@ class IdealPostcodes(Transport):
|
|
|
872
905
|
bias_country=bias_country,
|
|
873
906
|
bias_lonlat=bias_lonlat,
|
|
874
907
|
tags=tags,
|
|
908
|
+
remove_organisation=remove_organisation,
|
|
875
909
|
dataset=dataset,
|
|
876
910
|
)
|
|
877
911
|
return cast(
|
|
@@ -907,6 +941,7 @@ class IdealPostcodes(Transport):
|
|
|
907
941
|
"bias_country": bias_country,
|
|
908
942
|
"bias_lonlat": bias_lonlat,
|
|
909
943
|
"tags": tags,
|
|
944
|
+
"remove_organisation": remove_organisation,
|
|
910
945
|
"dataset": dataset,
|
|
911
946
|
},
|
|
912
947
|
),
|
|
@@ -37,14 +37,14 @@ class DeleteLicenseeResult(BaseModel):
|
|
|
37
37
|
model_config = ConfigDict(
|
|
38
38
|
extra="allow",
|
|
39
39
|
)
|
|
40
|
-
deleted: Annotated[
|
|
40
|
+
deleted: Annotated[int, Field(examples=[1], ge=0)]
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
class DeleteConfigResult(BaseModel):
|
|
44
44
|
model_config = ConfigDict(
|
|
45
45
|
extra="allow",
|
|
46
46
|
)
|
|
47
|
-
deleted: Annotated[
|
|
47
|
+
deleted: Annotated[int, Field(examples=[1], ge=0)]
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
class ProjectedAddressesResult(BaseModel):
|
|
@@ -733,7 +733,7 @@ class AbpAddress(BaseModel):
|
|
|
733
733
|
classification_code: Annotated[
|
|
734
734
|
str | None,
|
|
735
735
|
Field(
|
|
736
|
-
description="Current AddressBase classification code (e.g. `RD`
|
|
736
|
+
description="Current AddressBase classification code, passed through verbatim at\nwhatever level the custodian recorded. Usually tertiary (e.g. `RD03`\nsemi-detached, `RD04` terraced, `RD06` self-contained flat, `CR01`\nretail), but can be quaternary (`LP03PA`), secondary (`RD`) or primary\n(`C`). Match on prefix rather than equality. Top-level categories: `R` Residential,\n`C` Commercial, `L` Land, `M` Military, `O` Other, `P` Parent shell,\n`U` Unclassified, `X` Dual use, `Z` Object of interest. NULL when no\ncurrent classification row exists for the UPRN.\n",
|
|
737
737
|
max_length=6,
|
|
738
738
|
title="Classification Code",
|
|
739
739
|
),
|
|
@@ -5655,11 +5655,11 @@ class Daily(BaseModel):
|
|
|
5655
5655
|
),
|
|
5656
5656
|
]
|
|
5657
5657
|
count: Annotated[
|
|
5658
|
-
|
|
5658
|
+
int,
|
|
5659
5659
|
Field(
|
|
5660
5660
|
description="The number of lookups performed by the licensee on the day represented by `licensees.daily.updatedAt`",
|
|
5661
5661
|
examples=[232],
|
|
5662
|
-
ge=0
|
|
5662
|
+
ge=0,
|
|
5663
5663
|
),
|
|
5664
5664
|
]
|
|
5665
5665
|
updatedAt: Annotated[
|
|
@@ -6646,17 +6646,17 @@ class GbrCleanseMatch(BaseModel):
|
|
|
6646
6646
|
query: Annotated[str, Field(description="Originally submitted query")]
|
|
6647
6647
|
match: Annotated[Match, Field(description="Nearest matching address")]
|
|
6648
6648
|
count: Annotated[
|
|
6649
|
-
|
|
6649
|
+
int,
|
|
6650
6650
|
Field(
|
|
6651
6651
|
description="The number of addresses we matched to the input. We return the closest match by default.\n",
|
|
6652
|
-
ge=0
|
|
6653
|
-
le=10
|
|
6652
|
+
ge=0,
|
|
6653
|
+
le=10,
|
|
6654
6654
|
),
|
|
6655
6655
|
]
|
|
6656
6656
|
fit: Annotated[
|
|
6657
6657
|
float,
|
|
6658
6658
|
Field(
|
|
6659
|
-
description="A score represented as number between 1 and 0. Fit compares the address elements present in your query against the matching address elements. It does not incorporate elements you have not presented in the score. A partial address (e.g. 12 Pye Green Road) will have a fit of 1 even though it is missing post town and postcode. Its confidence score will be less than 1 however because it is missing some crucial elements.\n",
|
|
6659
|
+
description="A score represented as a number between 1 and 0. Fit compares the address elements present in your query against the matching address elements. It does not incorporate elements you have not presented in the score. A partial address (e.g. 12 Pye Green Road) will have a fit of 1 even though it is missing post town and postcode. Its confidence score will be less than 1 however because it is missing some crucial elements.\n",
|
|
6660
6660
|
ge=0.0,
|
|
6661
6661
|
le=1.0,
|
|
6662
6662
|
),
|
|
@@ -6664,7 +6664,7 @@ class GbrCleanseMatch(BaseModel):
|
|
|
6664
6664
|
confidence: Annotated[
|
|
6665
6665
|
float,
|
|
6666
6666
|
Field(
|
|
6667
|
-
description="A confidence score represented as number between 1 and 0. 1 indicates a full match. 0 indicates no complete matching elements.\n",
|
|
6667
|
+
description="A confidence score represented as a number between 1 and 0. 1 indicates a full match. 0 indicates no complete matching elements.\n",
|
|
6668
6668
|
ge=0.0,
|
|
6669
6669
|
le=1.0,
|
|
6670
6670
|
),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|