karrio-generic 2025.5__py3-none-any.whl
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.
- karrio/mappers/generic/__init__.py +3 -0
- karrio/mappers/generic/mapper.py +38 -0
- karrio/mappers/generic/proxy.py +15 -0
- karrio/mappers/generic/settings.py +36 -0
- karrio/plugins/generic/__init__.py +19 -0
- karrio/providers/generic/__init__.py +0 -0
- karrio/providers/generic/units.py +81 -0
- karrio/providers/generic/utils.py +21 -0
- karrio_generic-2025.5.dist-info/METADATA +44 -0
- karrio_generic-2025.5.dist-info/RECORD +13 -0
- karrio_generic-2025.5.dist-info/WHEEL +5 -0
- karrio_generic-2025.5.dist-info/entry_points.txt +2 -0
- karrio_generic-2025.5.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from typing import List, Tuple
|
|
2
|
+
from karrio.core.utils.serializable import Serializable, Deserializable
|
|
3
|
+
from karrio.api.mapper import Mapper as BaseMapper
|
|
4
|
+
from karrio.core.models import (
|
|
5
|
+
RateDetails,
|
|
6
|
+
RateRequest,
|
|
7
|
+
Message,
|
|
8
|
+
ShipmentDetails,
|
|
9
|
+
)
|
|
10
|
+
from karrio.universal.providers.shipping import (
|
|
11
|
+
parse_shipment_response,
|
|
12
|
+
shipment_request,
|
|
13
|
+
)
|
|
14
|
+
from karrio.universal.providers.rating import (
|
|
15
|
+
parse_rate_response,
|
|
16
|
+
rate_request,
|
|
17
|
+
)
|
|
18
|
+
from karrio.mappers.generic.settings import Settings
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Mapper(BaseMapper):
|
|
22
|
+
settings: Settings
|
|
23
|
+
|
|
24
|
+
def create_rate_request(self, payload: RateRequest) -> Serializable:
|
|
25
|
+
return rate_request(payload, self.settings)
|
|
26
|
+
|
|
27
|
+
def create_shipment_request(self, payload: Serializable) -> Serializable:
|
|
28
|
+
return shipment_request(payload, self.settings)
|
|
29
|
+
|
|
30
|
+
def parse_rate_response(
|
|
31
|
+
self, response: Deserializable
|
|
32
|
+
) -> Tuple[List[RateDetails], List[Message]]:
|
|
33
|
+
return parse_rate_response(response, self.settings)
|
|
34
|
+
|
|
35
|
+
def parse_shipment_response(
|
|
36
|
+
self, response: Deserializable
|
|
37
|
+
) -> Tuple[ShipmentDetails, List[Message]]:
|
|
38
|
+
return parse_shipment_response(response, self.settings)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from karrio.api.proxy import Proxy as BaseProxy
|
|
2
|
+
from karrio.universal.mappers.rating_proxy import RatingMixinProxy
|
|
3
|
+
from karrio.universal.mappers.shipping_proxy import ShippingMixinProxy
|
|
4
|
+
from karrio.mappers.generic.settings import Settings
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Proxy = type(
|
|
8
|
+
"Proxy",
|
|
9
|
+
(BaseProxy,),
|
|
10
|
+
dict(
|
|
11
|
+
settings=Settings,
|
|
12
|
+
get_rates=RatingMixinProxy.get_rates,
|
|
13
|
+
create_shipment=ShippingMixinProxy.create_shipment,
|
|
14
|
+
),
|
|
15
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Karrio Generic client settings."""
|
|
2
|
+
|
|
3
|
+
import attr
|
|
4
|
+
import typing
|
|
5
|
+
import jstruct
|
|
6
|
+
import karrio.core.models as models
|
|
7
|
+
import karrio.providers.generic.units as provider_units
|
|
8
|
+
import karrio.providers.generic.utils as provider_utils
|
|
9
|
+
import karrio.universal.mappers.rating_proxy as rating_proxy
|
|
10
|
+
import karrio.universal.mappers.shipping_proxy as shipping_proxy
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@attr.s(auto_attribs=True)
|
|
14
|
+
class Settings(provider_utils.Settings, rating_proxy.RatingMixinSettings, shipping_proxy.ShippingMixinSettings):
|
|
15
|
+
"""Generic connection settings."""
|
|
16
|
+
|
|
17
|
+
display_name: str
|
|
18
|
+
custom_carrier_name: str
|
|
19
|
+
|
|
20
|
+
test_mode: bool = False
|
|
21
|
+
carrier_id: str = "custom-carrier"
|
|
22
|
+
account_country_code: str = None
|
|
23
|
+
account_number: str = None
|
|
24
|
+
metadata: dict = {}
|
|
25
|
+
config: dict = {}
|
|
26
|
+
id: str = None
|
|
27
|
+
|
|
28
|
+
label_template: models.LabelTemplate = jstruct.JStruct[models.LabelTemplate]
|
|
29
|
+
services: typing.List[models.ServiceLevel] = jstruct.JList[models.ServiceLevel, False, dict(default=provider_units.DEFAULT_SERVICES)] # type: ignore
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def shipping_services(self) -> typing.List[models.ServiceLevel]:
|
|
33
|
+
if any(self.services or []):
|
|
34
|
+
return self.services
|
|
35
|
+
|
|
36
|
+
return provider_units.DEFAULT_SERVICES
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import karrio.core.metadata as metadata
|
|
2
|
+
import karrio.mappers.generic as mappers
|
|
3
|
+
import karrio.providers.generic.units as units
|
|
4
|
+
|
|
5
|
+
METADATA = metadata.PluginMetadata(
|
|
6
|
+
status="production-ready",
|
|
7
|
+
id="generic",
|
|
8
|
+
label="Custom Carrier",
|
|
9
|
+
# Integrations
|
|
10
|
+
Mapper=mappers.Mapper,
|
|
11
|
+
Proxy=mappers.Proxy,
|
|
12
|
+
Settings=mappers.Settings,
|
|
13
|
+
# Data Units
|
|
14
|
+
services=units.Service,
|
|
15
|
+
options=units.Option,
|
|
16
|
+
service_levels=units.DEFAULT_SERVICES,
|
|
17
|
+
connection_configs=units.ConnectionConfig,
|
|
18
|
+
has_intl_accounts=True,
|
|
19
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import karrio.lib as lib
|
|
2
|
+
import karrio.core.models as models
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ConnectionConfig(lib.Enum):
|
|
6
|
+
text_color = lib.OptionEnum("text_color")
|
|
7
|
+
brand_color = lib.OptionEnum("brand_color")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Service(lib.Enum):
|
|
11
|
+
standard_service = "standard"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Option(lib.Enum):
|
|
15
|
+
tracking_number_reference = lib.OptionEnum("tracking_number")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
DEFAULT_SERVICES = [
|
|
19
|
+
models.ServiceLevel(
|
|
20
|
+
service_name="Standard Service",
|
|
21
|
+
service_code="standard_service",
|
|
22
|
+
currency="USD",
|
|
23
|
+
transit_days=1,
|
|
24
|
+
zones=[models.ServiceZone(label="Zone 1", rate=0.0)],
|
|
25
|
+
),
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
SAMPLE_SHIPMENT_REQUEST = {
|
|
29
|
+
"service": "carrier_premium",
|
|
30
|
+
"label_type": "ZPL",
|
|
31
|
+
"shipper": {
|
|
32
|
+
"company_name": "CGI",
|
|
33
|
+
"address_line1": "502 MAIN ST N",
|
|
34
|
+
"city": "MONTREAL",
|
|
35
|
+
"postal_code": "H2B1A0",
|
|
36
|
+
"country_code": "CA",
|
|
37
|
+
"person_name": "Bob",
|
|
38
|
+
"phone_number": "1 (450) 823-8432",
|
|
39
|
+
"state_code": "QC",
|
|
40
|
+
},
|
|
41
|
+
"recipient": {
|
|
42
|
+
"company_name": "CGI",
|
|
43
|
+
"address_line1": "23 jardin private",
|
|
44
|
+
"city": "Ottawa",
|
|
45
|
+
"postal_code": "K1K4T3",
|
|
46
|
+
"country_code": "CA",
|
|
47
|
+
"person_name": "Jain",
|
|
48
|
+
"state_code": "ON",
|
|
49
|
+
},
|
|
50
|
+
"parcels": [
|
|
51
|
+
{
|
|
52
|
+
"height": 3.0,
|
|
53
|
+
"length": 5.0,
|
|
54
|
+
"width": 3.0,
|
|
55
|
+
"weight": 4.0,
|
|
56
|
+
"dimension_unit": "IN",
|
|
57
|
+
"weight_unit": "LB",
|
|
58
|
+
"reference_number": "2975565",
|
|
59
|
+
"items": [
|
|
60
|
+
{
|
|
61
|
+
"weight": 1.0,
|
|
62
|
+
"weight_unit": "LB",
|
|
63
|
+
"quantity": 1,
|
|
64
|
+
"title": "Item 1",
|
|
65
|
+
"sku": "SKU-1",
|
|
66
|
+
"metadata": {
|
|
67
|
+
"RFF_CN": "037-2332855",
|
|
68
|
+
"BGM": "040000000000016256",
|
|
69
|
+
"RFF_ON": "5424560",
|
|
70
|
+
"DEPT": "DBR128",
|
|
71
|
+
"CTL": "11253678",
|
|
72
|
+
"XXNC": "138039C01",
|
|
73
|
+
"NAD_UD": "570162",
|
|
74
|
+
"RFF_AJY": "907",
|
|
75
|
+
"RFF_AEM": "3901L",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Karrio Generic client settings."""
|
|
2
|
+
|
|
3
|
+
import karrio.lib as lib
|
|
4
|
+
from karrio.core.settings import Settings as BaseSettings
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Settings(BaseSettings):
|
|
8
|
+
"""Generic connection settings."""
|
|
9
|
+
|
|
10
|
+
@property
|
|
11
|
+
def carrier_name(self):
|
|
12
|
+
return "generic"
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def connection_config(self) -> lib.units.Options:
|
|
16
|
+
from karrio.providers.generic.units import ConnectionConfig
|
|
17
|
+
|
|
18
|
+
return lib.to_connection_config(
|
|
19
|
+
self.config or {},
|
|
20
|
+
option_type=ConnectionConfig,
|
|
21
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: karrio_generic
|
|
3
|
+
Version: 2025.5
|
|
4
|
+
Summary: Karrio - Custom carrier Shipping extension
|
|
5
|
+
Author-email: karrio <hello@karrio.io>
|
|
6
|
+
License-Expression: LGPL-3.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/karrioapi/karrio
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: karrio
|
|
14
|
+
|
|
15
|
+
# karrio.generic
|
|
16
|
+
|
|
17
|
+
This package is a Generic extension of the [karrio](https://pypi.org/project/karrio) multi carrier shipping SDK.
|
|
18
|
+
|
|
19
|
+
## Requirements
|
|
20
|
+
|
|
21
|
+
`Python 3.11+`
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install karrio.generic
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import karrio.sdk as karrio
|
|
33
|
+
from karrio.mappers.generic.settings import Settings
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# Initialize a carrier gateway
|
|
37
|
+
canadapost = karrio.gateway["generic"].create(
|
|
38
|
+
Settings(
|
|
39
|
+
...
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Check the [Karrio Mutli-carrier SDK docs](https://docs.karrio.io) for Shipping API requests
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
karrio/mappers/generic/__init__.py,sha256=eizJesNxYg-FdtvbWso16wcpdnuClROT4Q-Df3d3eec,149
|
|
2
|
+
karrio/mappers/generic/mapper.py,sha256=vzWGp4DzadAmrUqzBZbVtDdy0-g55iPKCXeSTWuXiCk,1182
|
|
3
|
+
karrio/mappers/generic/proxy.py,sha256=nQxbLSwouoP_Vm0sjiutsELSEQEfz96ZYEqR7I3QAgM,438
|
|
4
|
+
karrio/mappers/generic/settings.py,sha256=O8HmiZUtJZRbGSCnYL-Y_ILrsJP-kPM8bK0HXDcdFfc,1226
|
|
5
|
+
karrio/plugins/generic/__init__.py,sha256=2jRHdsHUevSCaW1WbQXNIucu3iplmPDp2ajJHlASHvw,535
|
|
6
|
+
karrio/providers/generic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
karrio/providers/generic/units.py,sha256=-nN2LvdEDVVbciU3iGyKn8zjm0L3TAfzju0PBzaawsY,2212
|
|
8
|
+
karrio/providers/generic/utils.py,sha256=dBlGrhkD4g2ZmkYnxKUF3H8hQgdhF5bpBKr8NQ5_bGA,523
|
|
9
|
+
karrio_generic-2025.5.dist-info/METADATA,sha256=aIjUAXFRWs5XG4NqhZR0UaK6iiSopiQeooZETsoL2os,998
|
|
10
|
+
karrio_generic-2025.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
11
|
+
karrio_generic-2025.5.dist-info/entry_points.txt,sha256=mvK1B8xIjTUc-b1CSXV7mlKxVW6F6qqRjW21i0COUOo,59
|
|
12
|
+
karrio_generic-2025.5.dist-info/top_level.txt,sha256=D1D7x8R3cTfjF_15mfiO7wCQ5QMtuM4x8GaPr7z5i78,12
|
|
13
|
+
karrio_generic-2025.5.dist-info/RECORD,,
|