biip.gs1_digital_link_uris
Support for GS1 Digital Link URIs.
GS1 Digital Link URIs are HTTPS URIs pointing to any hostname, optionally with a path prefix, where GS1 element strings are encoded in the path and query parameters.
Examples of GS1 Digital Link URIs:
https://id.gs1.org/01/614141123452/lot/ABC1/ser/12345?exp=180426https://id.gs1.org/01/614141123452?3103=000195https://id.gs1.org/00/106141412345678908?02=00614141123452&37=25&10=ABC123
This makes it possible to use GS1 Digital Link URIs encoded in 2D barcodes both in supply chain and logistics applications, as well as for consumers to look up product information.
Example
If you only want to parse GS1 Digital Link URIs, you can import the GS1 Digital
Link URI parser directly instead of using biip.parse().
>>> from biip.gs1_digital_link_uris import GS1DigitalLinkURI
If the parsing succeeds, it returns a
GS1DigitalLinkURI object.
>>> dl_uri = GS1DigitalLinkURI.parse("https://id.gs1.org/00/106141412345678908?02=00614141123452&37=25&10=ABC123")
In this case, the URI is parsed into the SSCC of a shipping container, the GTIN of the product within the shipping container, the number of item within, and the batch number.
>>> pprint(dl_uri.element_strings)
[
GS1ElementString(
ai=GS1ApplicationIdentifier(
ai='00',
description='Serial Shipping Container Code (SSCC)',
data_title='SSCC',
separator_required=False,
format='N2+N18'
),
value='106141412345678908',
pattern_groups=[
'106141412345678908'
],
sscc=Sscc(
value='106141412345678908',
prefix=GS1Prefix(
value='061',
usage='GS1 US'
),
company_prefix=GS1CompanyPrefix(
value='0614141'
),
extension_digit=1,
payload='10614141234567890',
check_digit=8
)
),
GS1ElementString(
ai=GS1ApplicationIdentifier(
ai='02',
description='Global Trade Item Number (GTIN) of contained trade items',
data_title='CONTENT',
separator_required=False,
format='N2+N14'
),
value='00614141123452',
pattern_groups=[
'00614141123452'
],
gtin=Gtin(
value='00614141123452',
format=GtinFormat.GTIN_12,
prefix=GS1Prefix(
value='061',
usage='GS1 US'
),
company_prefix=GS1CompanyPrefix(
value='0614141'
),
item_reference='12345',
payload='61414112345',
check_digit=2
)
),
GS1ElementString(
ai=GS1ApplicationIdentifier(
ai='37',
description='Count of trade items or trade item pieces contained in a logistic unit',
data_title='COUNT',
separator_required=True,
format='N2+N..8'
),
value='25',
pattern_groups=[
'25'
]
),
GS1ElementString(
ai=GS1ApplicationIdentifier(
ai='10',
description='Batch or lot number',
data_title='BATCH/LOT',
separator_required=True,
format='N2+X..20'
),
value='ABC123',
pattern_groups=[
'ABC123'
]
)
]
GS1DigitalLinkURI
dataclass
A GS1 Digital Link URI is a URI that contains GS1 element strings.
Source code in src/biip/gs1_digital_link_uris.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
element_strings
instance-attribute
List of element strings found in the message.
See GS1ElementStrings for
methods to extract interesting element strings from the list.
as_canonical_uri
Render as a canonical GS1 Digital Link URI.
Canonical URIs:
- Use the domain name
id.gs1.org. - Uses numeric AI values in the URI path.
- Excludes all query parameters that are not valid application identifiers.
Returns:
-
str(str) –The canonical GS1 Digital Link URI.
References
GS1 Digital Link Standard: URI Syntax, section 4.12
Source code in src/biip/gs1_digital_link_uris.py
as_gs1_message
Converts the GS1 Digital Link URI to a GS1 Message.
as_uri
Render as a GS1 Digital Link URI.
Parameters:
-
domain(str | None, default:None) –The domain name to use in the URI. Defaults to
id.gs1.org. -
prefix(str | None, default:None) –The path prefix to use in the URI. Defaults to no prefix.
Returns:
-
str(str) –The GS1 Digital Link URI.
Source code in src/biip/gs1_digital_link_uris.py
from_element_strings
classmethod
Create a GS1 Digital Link URI from a list of GS1 element strings.
Parameters:
-
element_strings(GS1ElementStrings) –A list of GS1 element strings.
Returns:
-
GS1DigitalLinkURI(GS1DigitalLinkURI) –The created GS1 Digital Link URI.
Source code in src/biip/gs1_digital_link_uris.py
parse
classmethod
Parse a string as a GS1 Digital Link URI.
Parameters:
-
value(str) –The string to parse.
-
config(ParseConfig | None, default:None) –The parse configuration.
Returns:
-
GS1DigitalLinkURI–The parsed GS1 Digital Link URI.
Raises:
-
ParseError–If the parsing fails.
Source code in src/biip/gs1_digital_link_uris.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |