karrio-server-core 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/server/conf.py +54 -0
- karrio/server/core/__init__.py +3 -0
- karrio/server/core/admin.py +1 -0
- karrio/server/core/apps.py +10 -0
- karrio/server/core/authentication.py +347 -0
- karrio/server/core/config.py +31 -0
- karrio/server/core/context_processors.py +12 -0
- karrio/server/core/datatypes.py +394 -0
- karrio/server/core/dataunits.py +187 -0
- karrio/server/core/exceptions.py +404 -0
- karrio/server/core/fields.py +12 -0
- karrio/server/core/filters.py +837 -0
- karrio/server/core/gateway.py +1011 -0
- karrio/server/core/logging.py +403 -0
- karrio/server/core/management/commands/cli.py +19 -0
- karrio/server/core/management/commands/create_oauth_client.py +41 -0
- karrio/server/core/management/commands/runserver.py +5 -0
- karrio/server/core/middleware.py +197 -0
- karrio/server/core/migrations/0001_initial.py +28 -0
- karrio/server/core/migrations/0002_apilogindex.py +69 -0
- karrio/server/core/migrations/0003_apilogindex_test_mode.py +62 -0
- karrio/server/core/migrations/0004_metafield.py +74 -0
- karrio/server/core/migrations/0005_alter_metafield_type_alter_metafield_value.py +23 -0
- karrio/server/core/migrations/0006_add_api_log_requested_at_index.py +22 -0
- karrio/server/core/migrations/__init__.py +0 -0
- karrio/server/core/models/__init__.py +48 -0
- karrio/server/core/models/base.py +103 -0
- karrio/server/core/models/entity.py +24 -0
- karrio/server/core/models/metafield.py +144 -0
- karrio/server/core/models/third_party.py +21 -0
- karrio/server/core/oauth_validators.py +170 -0
- karrio/server/core/permissions.py +36 -0
- karrio/server/core/renderers.py +11 -0
- karrio/server/core/router.py +3 -0
- karrio/server/core/serializers.py +1971 -0
- karrio/server/core/signals.py +55 -0
- karrio/server/core/telemetry.py +573 -0
- karrio/server/core/tests.py +99 -0
- karrio/server/core/tests_resource_token.py +411 -0
- karrio/server/core/urls.py +12 -0
- karrio/server/core/utils.py +1025 -0
- karrio/server/core/validators.py +264 -0
- karrio/server/core/views/__init__.py +2 -0
- karrio/server/core/views/api.py +133 -0
- karrio/server/core/views/metadata.py +44 -0
- karrio/server/core/views/oauth.py +75 -0
- karrio/server/core/views/references.py +82 -0
- karrio/server/core/views/schema.py +310 -0
- karrio/server/filters/__init__.py +2 -0
- karrio/server/filters/abstract.py +26 -0
- karrio/server/iam/__init__.py +0 -0
- karrio/server/iam/admin.py +3 -0
- karrio/server/iam/apps.py +21 -0
- karrio/server/iam/migrations/0001_initial.py +33 -0
- karrio/server/iam/migrations/__init__.py +0 -0
- karrio/server/iam/models.py +48 -0
- karrio/server/iam/permissions.py +155 -0
- karrio/server/iam/serializers.py +54 -0
- karrio/server/iam/signals.py +18 -0
- karrio/server/iam/tests.py +3 -0
- karrio/server/iam/views.py +3 -0
- karrio/server/openapi.py +75 -0
- karrio/server/providers/__init__.py +1 -0
- karrio/server/providers/admin.py +364 -0
- karrio/server/providers/apps.py +10 -0
- karrio/server/providers/management/commands/migrate_rate_sheets.py +101 -0
- karrio/server/providers/migrations/0001_initial.py +140 -0
- karrio/server/providers/migrations/0002_carrier_active.py +18 -0
- karrio/server/providers/migrations/0003_auto_20201230_0820.py +24 -0
- karrio/server/providers/migrations/0004_auto_20210212_0554.py +178 -0
- karrio/server/providers/migrations/0005_auto_20210212_0555.py +18 -0
- karrio/server/providers/migrations/0006_australiapostsettings.py +29 -0
- karrio/server/providers/migrations/0007_auto_20210213_0206.py +21 -0
- karrio/server/providers/migrations/0008_auto_20210214_0409.py +30 -0
- karrio/server/providers/migrations/0009_auto_20210308_0302.py +18 -0
- karrio/server/providers/migrations/0010_auto_20210409_0852.py +32 -0
- karrio/server/providers/migrations/0011_auto_20210409_0853.py +21 -0
- karrio/server/providers/migrations/0012_alter_carrier_options.py +17 -0
- karrio/server/providers/migrations/0013_tntsettings.py +30 -0
- karrio/server/providers/migrations/0014_auto_20210612_1608.py +46 -0
- karrio/server/providers/migrations/0015_auto_20210615_1601.py +28 -0
- karrio/server/providers/migrations/0016_alter_purolatorsettings_user_token.py +18 -0
- karrio/server/providers/migrations/0017_auto_20210805_0359.py +1293 -0
- karrio/server/providers/migrations/0018_alter_fedexsettings_user_key.py +18 -0
- karrio/server/providers/migrations/0019_dhlpolandsettings_servicelevel.py +65 -0
- karrio/server/providers/migrations/0020_genericsettings_labeltemplate.py +52 -0
- karrio/server/providers/migrations/0021_auto_20211231_2353.py +40 -0
- karrio/server/providers/migrations/0022_carrier_metadata.py +18 -0
- karrio/server/providers/migrations/0023_auto_20220124_1916.py +27 -0
- karrio/server/providers/migrations/0024_alter_genericsettings_custom_carrier_name.py +19 -0
- karrio/server/providers/migrations/0025_alter_servicelevel_service_code.py +19 -0
- karrio/server/providers/migrations/0026_auto_20220208_0132.py +59 -0
- karrio/server/providers/migrations/0027_auto_20220304_1340.py +29 -0
- karrio/server/providers/migrations/0028_auto_20220323_1500.py +33 -0
- karrio/server/providers/migrations/0029_easypostsettings.py +27 -0
- karrio/server/providers/migrations/0030_amazonmwssettings.py +29 -0
- karrio/server/providers/migrations/0031_delete_amazonmwssettings.py +18 -0
- karrio/server/providers/migrations/0032_alter_carrier_test.py +18 -0
- karrio/server/providers/migrations/0033_auto_20220708_1350.py +22 -0
- karrio/server/providers/migrations/0034_amazonmwssettings_dpdhlsettings.py +47 -0
- karrio/server/providers/migrations/0035_alter_carrier_capabilities.py +43 -0
- karrio/server/providers/migrations/0036_upsfreightsettings.py +31 -0
- karrio/server/providers/migrations/0037_chronopostsettings.py +29 -0
- karrio/server/providers/migrations/0038_alter_genericsettings_label_template.py +19 -0
- karrio/server/providers/migrations/0039_auto_20220906_0612.py +23 -0
- karrio/server/providers/migrations/0040_dpdhlsettings_services.py +18 -0
- karrio/server/providers/migrations/0041_auto_20221105_0705.py +38 -0
- karrio/server/providers/migrations/0042_auto_20221215_1642.py +23 -0
- karrio/server/providers/migrations/0043_alter_genericsettings_account_number_and_more.py +39 -0
- karrio/server/providers/migrations/0044_carrier_carrier_capabilities.py +64 -0
- karrio/server/providers/migrations/0045_alter_carrier_active_alter_carrier_carrier_id.py +31 -0
- karrio/server/providers/migrations/0046_remove_dpdhlsettings_signature_and_more.py +41 -0
- karrio/server/providers/migrations/0047_dpdsettings.py +286 -0
- karrio/server/providers/migrations/0048_servicelevel_min_weight_servicelevel_transit_days_and_more.py +64 -0
- karrio/server/providers/migrations/0049_boxknightsettings_geodissettings_lapostesettings_and_more.py +156 -0
- karrio/server/providers/migrations/0050_carrier_is_system_alter_carrier_metadata_and_more.py +106 -0
- karrio/server/providers/migrations/0051_rename_username_upssettings_client_id_and_more.py +31 -0
- karrio/server/providers/migrations/0052_alter_upssettings_account_number_and_more.py +20 -0
- karrio/server/providers/migrations/0053_locate2usettings.py +281 -0
- karrio/server/providers/migrations/0054_zoom2usettings.py +280 -0
- karrio/server/providers/migrations/0055_rename_amazonmwssettings_amazonshippingsettings_and_more.py +44 -0
- karrio/server/providers/migrations/0056_asendiaussettings_geodissettings_code_client_and_more.py +75 -0
- karrio/server/providers/migrations/0057_alter_servicelevel_weight_unit_belgianpostsettings.py +51 -0
- karrio/server/providers/migrations/0058_alliedexpresssettings.py +38 -0
- karrio/server/providers/migrations/0059_ratesheet.py +81 -0
- karrio/server/providers/migrations/0060_belgianpostsettings_rate_sheet_and_more.py +73 -0
- karrio/server/providers/migrations/0061_alliedexpresssettings_service_type.py +17 -0
- karrio/server/providers/migrations/0062_sendlesettings_account_country_code.py +257 -0
- karrio/server/providers/migrations/0063_servicelevel_metadata.py +25 -0
- karrio/server/providers/migrations/0064_alliedexpresslocalsettings.py +43 -0
- karrio/server/providers/migrations/0065_servicelevel_carrier_service_code_and_more.py +66 -0
- karrio/server/providers/migrations/0066_rename_fedexsettings_fedexwssettings_and_more.py +28 -0
- karrio/server/providers/migrations/0067_fedexsettings.py +283 -0
- karrio/server/providers/migrations/0068_fedexsettings_track_api_key_and_more.py +38 -0
- karrio/server/providers/migrations/0069_alter_canadapostsettings_contract_id_and_more.py +23 -0
- karrio/server/providers/migrations/0070_tgesettings_alter_carrier_capabilities.py +65 -0
- karrio/server/providers/migrations/0071_alter_tgesettings_my_toll_token.py +18 -0
- karrio/server/providers/migrations/0072_rename_eshippersettings_eshipperxmlsettings_and_more.py +28 -0
- karrio/server/providers/migrations/0073_delete_eshipperxmlsettings.py +41 -0
- karrio/server/providers/migrations/0074_eshippersettings.py +38 -0
- karrio/server/providers/migrations/0075_haypostsettings.py +40 -0
- karrio/server/providers/migrations/0076_rename_customer_registration_id_uspsinternationalsettings_account_number_and_more.py +125 -0
- karrio/server/providers/migrations/0077_uspswtinternationalsettings_uspswtsettings_and_more.py +165 -0
- karrio/server/providers/migrations/0078_auto_20240813_1552.py +120 -0
- karrio/server/providers/migrations/0079_alter_carrier_options_alter_ratesheet_created_by.py +31 -0
- karrio/server/providers/migrations/0080_alter_aramexsettings_account_country_code_and_more.py +3025 -0
- karrio/server/providers/migrations/0081_remove_alliedexpresssettings_carrier_ptr_and_more.py +338 -0
- karrio/server/providers/migrations/0082_add_zone_identifiers.py +50 -0
- karrio/server/providers/migrations/0083_add_optimized_rate_sheet_structure.py +33 -0
- karrio/server/providers/migrations/0084_alter_servicelevel_currency.py +168 -0
- karrio/server/providers/migrations/0085_populate_dhl_parcel_de_oauth_credentials.py +82 -0
- karrio/server/providers/migrations/0086_rename_dhl_parcel_de_customer_number_to_billing_number.py +71 -0
- karrio/server/providers/migrations/__init__.py +0 -0
- karrio/server/providers/models/__init__.py +16 -0
- karrio/server/providers/models/carrier.py +387 -0
- karrio/server/providers/models/config.py +30 -0
- karrio/server/providers/models/service.py +192 -0
- karrio/server/providers/models/sheet.py +287 -0
- karrio/server/providers/models/template.py +39 -0
- karrio/server/providers/models/utils.py +58 -0
- karrio/server/providers/router.py +3 -0
- karrio/server/providers/serializers/__init__.py +3 -0
- karrio/server/providers/serializers/base.py +538 -0
- karrio/server/providers/signals.py +25 -0
- karrio/server/providers/templates/providers/oauth_callback.html +105 -0
- karrio/server/providers/tests/__init__.py +5 -0
- karrio/server/providers/tests/test_connections.py +895 -0
- karrio/server/providers/urls.py +11 -0
- karrio/server/providers/views/__init__.py +0 -0
- karrio/server/providers/views/carriers.py +267 -0
- karrio/server/providers/views/connections.py +496 -0
- karrio/server/samples.py +352 -0
- karrio/server/serializers/__init__.py +2 -0
- karrio/server/serializers/abstract.py +602 -0
- karrio/server/tracing/__init__.py +0 -0
- karrio/server/tracing/admin.py +63 -0
- karrio/server/tracing/apps.py +8 -0
- karrio/server/tracing/migrations/0001_initial.py +41 -0
- karrio/server/tracing/migrations/0002_auto_20220710_1307.py +22 -0
- karrio/server/tracing/migrations/0003_auto_20221105_0317.py +43 -0
- karrio/server/tracing/migrations/0004_tracingrecord_carrier_account_idx.py +24 -0
- karrio/server/tracing/migrations/0005_optimise_tracingrecord_request_log_idx.py +25 -0
- karrio/server/tracing/migrations/0006_alter_tracingrecord_options_and_more.py +49 -0
- karrio/server/tracing/migrations/0007_tracingrecord_tracing_created_at_idx.py +19 -0
- karrio/server/tracing/migrations/__init__.py +0 -0
- karrio/server/tracing/models.py +82 -0
- karrio/server/tracing/tests.py +3 -0
- karrio/server/tracing/utils.py +109 -0
- karrio/server/user/__init__.py +0 -0
- karrio/server/user/admin.py +96 -0
- karrio/server/user/apps.py +7 -0
- karrio/server/user/forms.py +35 -0
- karrio/server/user/migrations/0001_initial.py +41 -0
- karrio/server/user/migrations/0002_token.py +29 -0
- karrio/server/user/migrations/0003_token_test_mode.py +20 -0
- karrio/server/user/migrations/0004_group.py +26 -0
- karrio/server/user/migrations/0005_token_label.py +21 -0
- karrio/server/user/migrations/0006_workspaceconfig.py +63 -0
- karrio/server/user/migrations/0007_user_metadata.py +25 -0
- karrio/server/user/migrations/__init__.py +0 -0
- karrio/server/user/models.py +218 -0
- karrio/server/user/serializers.py +47 -0
- karrio/server/user/templates/registration/login.html +108 -0
- karrio/server/user/templates/registration/registration_confirm_email.html +10 -0
- karrio/server/user/templates/registration/registration_confirm_email.txt +3 -0
- karrio/server/user/tests.py +3 -0
- karrio/server/user/urls.py +10 -0
- karrio/server/user/utils.py +60 -0
- karrio/server/user/views.py +9 -0
- karrio_server_core-2025.5.dist-info/METADATA +32 -0
- karrio_server_core-2025.5.dist-info/RECORD +213 -0
- karrio_server_core-2025.5.dist-info/WHEEL +5 -0
- karrio_server_core-2025.5.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,1971 @@
|
|
|
1
|
+
import rest_framework as drf
|
|
2
|
+
|
|
3
|
+
import karrio.core.units as units
|
|
4
|
+
import karrio.core.utils as utils
|
|
5
|
+
import karrio.server.serializers as serializers
|
|
6
|
+
import karrio.server.core.dataunits as dataunits
|
|
7
|
+
import karrio.server.core.validators as validators
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ShipmentStatus(utils.Enum):
|
|
11
|
+
draft = "draft"
|
|
12
|
+
purchased = "purchased"
|
|
13
|
+
cancelled = "cancelled"
|
|
14
|
+
shipped = "shipped"
|
|
15
|
+
in_transit = "in_transit"
|
|
16
|
+
delivered = "delivered"
|
|
17
|
+
needs_attention = "needs_attention"
|
|
18
|
+
out_for_delivery = "out_for_delivery"
|
|
19
|
+
delivery_failed = "delivery_failed"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TrackerStatus(utils.Enum):
|
|
23
|
+
pending = "pending"
|
|
24
|
+
unknown = "unknown"
|
|
25
|
+
on_hold = "on_hold"
|
|
26
|
+
cancelled = "cancelled"
|
|
27
|
+
delivered = "delivered"
|
|
28
|
+
in_transit = "in_transit"
|
|
29
|
+
delivery_delayed = "delivery_delayed"
|
|
30
|
+
out_for_delivery = "out_for_delivery"
|
|
31
|
+
ready_for_pickup = "ready_for_pickup"
|
|
32
|
+
delivery_failed = "delivery_failed"
|
|
33
|
+
return_to_sender = "return_to_sender"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
Serializer = serializers.Serializer
|
|
37
|
+
HTTP_STATUS = [getattr(drf.status, a) for a in dir(drf.status) if "HTTP" in a]
|
|
38
|
+
SHIPMENT_STATUS = [(c.name, c.name) for c in list(ShipmentStatus)]
|
|
39
|
+
TRACKER_STATUS = [(c.name, c.name) for c in list(TrackerStatus)]
|
|
40
|
+
INCOTERMS = [(c.name, c.name) for c in list(units.Incoterm)]
|
|
41
|
+
CARRIERS = [(k, k) for k in dataunits.CARRIER_NAMES]
|
|
42
|
+
COUNTRIES = [(c.name, c.name) for c in list(units.Country)]
|
|
43
|
+
CURRENCIES = [(c.name, c.name) for c in list(units.Currency)]
|
|
44
|
+
WEIGHT_UNIT = [(c.name, c.name) for c in list(units.WeightUnit)]
|
|
45
|
+
PAYMENT_TYPES = [(c.name, c.name) for c in list(units.PaymentType)]
|
|
46
|
+
DIMENSION_UNIT = [(c.name, c.name) for c in list(units.DimensionUnit)]
|
|
47
|
+
PACKAGING_UNIT = [(c.name, c.name) for c in list(units.PackagingUnit)]
|
|
48
|
+
CUSTOMS_CONTENT_TYPE = [(c.name, c.name) for c in list(units.CustomsContentType)]
|
|
49
|
+
UPLOAD_DOCUMENT_TYPE = [(c.name, c.name) for c in list(units.UploadDocumentType)]
|
|
50
|
+
LABEL_TYPES = [(c.name, c.name) for c in list(units.LabelType)]
|
|
51
|
+
LABEL_TEMPLATE_TYPES = [("SVG", "SVG"), ("ZPL", "ZPL")]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class CarrierDetails(serializers.Serializer):
|
|
55
|
+
carrier_name = serializers.ChoiceField(
|
|
56
|
+
choices=CARRIERS,
|
|
57
|
+
help_text="Indicates a carrier (type)",
|
|
58
|
+
)
|
|
59
|
+
display_name = serializers.CharField(
|
|
60
|
+
help_text="The carrier verbose name.",
|
|
61
|
+
)
|
|
62
|
+
integration_status = serializers.ChoiceField(
|
|
63
|
+
choices=[
|
|
64
|
+
("in-development", "In Development"),
|
|
65
|
+
("beta", "Beta"),
|
|
66
|
+
("production-ready", "Production Ready"),
|
|
67
|
+
],
|
|
68
|
+
help_text="The carrier integration status.",
|
|
69
|
+
)
|
|
70
|
+
capabilities = serializers.StringListField(
|
|
71
|
+
default=[],
|
|
72
|
+
help_text="""The carrier supported and enabled capabilities.""",
|
|
73
|
+
)
|
|
74
|
+
connection_fields = serializers.PlainDictField(
|
|
75
|
+
default={},
|
|
76
|
+
help_text="The carrier connection fields.",
|
|
77
|
+
)
|
|
78
|
+
config_fields = serializers.PlainDictField(
|
|
79
|
+
default={},
|
|
80
|
+
help_text="The carrier connection config.",
|
|
81
|
+
)
|
|
82
|
+
shipping_services = serializers.PlainDictField(
|
|
83
|
+
default={},
|
|
84
|
+
help_text="The carrier shipping services.",
|
|
85
|
+
)
|
|
86
|
+
shipping_options = serializers.PlainDictField(
|
|
87
|
+
default={},
|
|
88
|
+
help_text="The carrier shipping options.",
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class CarrierSettings(serializers.Serializer):
|
|
93
|
+
id = serializers.CharField(required=True, help_text="A unique address identifier")
|
|
94
|
+
object_type = serializers.CharField(
|
|
95
|
+
default="carrier", help_text="Specifies the object type"
|
|
96
|
+
)
|
|
97
|
+
carrier_id = serializers.CharField(
|
|
98
|
+
required=True, help_text="Indicates a specific carrier configuration name."
|
|
99
|
+
)
|
|
100
|
+
carrier_name = serializers.ChoiceField(
|
|
101
|
+
choices=CARRIERS, required=True, help_text="Indicates a carrier (type)"
|
|
102
|
+
)
|
|
103
|
+
display_name = serializers.CharField(
|
|
104
|
+
required=False, help_text="The carrier verbose name."
|
|
105
|
+
)
|
|
106
|
+
test_mode = serializers.BooleanField(
|
|
107
|
+
required=True,
|
|
108
|
+
help_text="The test flag indicates whether to use a carrier configured for test.",
|
|
109
|
+
)
|
|
110
|
+
active = serializers.BooleanField(
|
|
111
|
+
required=True,
|
|
112
|
+
help_text="The active flag indicates whether the carrier account is active or not.",
|
|
113
|
+
)
|
|
114
|
+
capabilities = serializers.StringListField(
|
|
115
|
+
required=False,
|
|
116
|
+
allow_null=True,
|
|
117
|
+
help_text="""The carrier supported and enabled capabilities.""",
|
|
118
|
+
)
|
|
119
|
+
metadata = serializers.PlainDictField(
|
|
120
|
+
required=False, default={}, help_text="The carrier user metadata."
|
|
121
|
+
)
|
|
122
|
+
config = serializers.PlainDictField(
|
|
123
|
+
required=False, default={}, help_text="The carrier connection config."
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class APIError(serializers.Serializer):
|
|
128
|
+
message = serializers.CharField(
|
|
129
|
+
required=False, help_text="The error or warning message"
|
|
130
|
+
)
|
|
131
|
+
code = serializers.CharField(required=False, help_text="The message code")
|
|
132
|
+
details = serializers.DictField(required=False, help_text="any additional details")
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class Message(APIError):
|
|
136
|
+
carrier_name = serializers.CharField(
|
|
137
|
+
required=False, help_text="The targeted carrier"
|
|
138
|
+
)
|
|
139
|
+
carrier_id = serializers.CharField(
|
|
140
|
+
required=False, help_text="The targeted carrier name (unique identifier)"
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class AddressValidation(serializers.Serializer):
|
|
145
|
+
success = serializers.BooleanField(help_text="True if the address is valid")
|
|
146
|
+
meta = serializers.PlainDictField(
|
|
147
|
+
required=False, allow_null=True, help_text="validation service details"
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class AddressData(validators.AugmentedAddressSerializer):
|
|
152
|
+
postal_code = serializers.CharField(
|
|
153
|
+
required=False,
|
|
154
|
+
allow_blank=True,
|
|
155
|
+
allow_null=True,
|
|
156
|
+
max_length=20,
|
|
157
|
+
help_text="""The address postal code
|
|
158
|
+
**(required for shipment purchase)**
|
|
159
|
+
""",
|
|
160
|
+
)
|
|
161
|
+
city = serializers.CharField(
|
|
162
|
+
required=False,
|
|
163
|
+
allow_blank=True,
|
|
164
|
+
allow_null=True,
|
|
165
|
+
max_length=50,
|
|
166
|
+
help_text="""The address city.
|
|
167
|
+
**(required for shipment purchase)**
|
|
168
|
+
""",
|
|
169
|
+
)
|
|
170
|
+
federal_tax_id = serializers.CharField(
|
|
171
|
+
required=False,
|
|
172
|
+
allow_blank=True,
|
|
173
|
+
allow_null=True,
|
|
174
|
+
max_length=50,
|
|
175
|
+
help_text="The party frederal tax id",
|
|
176
|
+
)
|
|
177
|
+
state_tax_id = serializers.CharField(
|
|
178
|
+
required=False,
|
|
179
|
+
allow_blank=True,
|
|
180
|
+
allow_null=True,
|
|
181
|
+
max_length=50,
|
|
182
|
+
help_text="The party state id",
|
|
183
|
+
)
|
|
184
|
+
person_name = serializers.CharField(
|
|
185
|
+
required=False,
|
|
186
|
+
allow_blank=True,
|
|
187
|
+
allow_null=True,
|
|
188
|
+
max_length=100,
|
|
189
|
+
help_text="""Attention to
|
|
190
|
+
**(required for shipment purchase)**
|
|
191
|
+
""",
|
|
192
|
+
)
|
|
193
|
+
company_name = serializers.CharField(
|
|
194
|
+
required=False,
|
|
195
|
+
allow_blank=True,
|
|
196
|
+
allow_null=True,
|
|
197
|
+
max_length=100,
|
|
198
|
+
help_text="The company name if the party is a company",
|
|
199
|
+
)
|
|
200
|
+
country_code = serializers.ChoiceField(
|
|
201
|
+
required=True,
|
|
202
|
+
choices=COUNTRIES,
|
|
203
|
+
help_text="The address country code",
|
|
204
|
+
)
|
|
205
|
+
email = serializers.CharField(
|
|
206
|
+
required=False, allow_blank=True, allow_null=True, help_text="The party email"
|
|
207
|
+
)
|
|
208
|
+
phone_number = serializers.CharField(
|
|
209
|
+
required=False,
|
|
210
|
+
allow_blank=True,
|
|
211
|
+
allow_null=True,
|
|
212
|
+
max_length=50,
|
|
213
|
+
help_text="The party phone number.",
|
|
214
|
+
)
|
|
215
|
+
state_code = serializers.CharField(
|
|
216
|
+
required=False,
|
|
217
|
+
allow_blank=True,
|
|
218
|
+
allow_null=True,
|
|
219
|
+
max_length=50,
|
|
220
|
+
help_text="The address state code",
|
|
221
|
+
)
|
|
222
|
+
residential = serializers.BooleanField(
|
|
223
|
+
allow_null=True,
|
|
224
|
+
required=False,
|
|
225
|
+
default=False,
|
|
226
|
+
help_text="Indicate if the address is residential or commercial (enterprise)",
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
street_number = serializers.CharField(
|
|
230
|
+
required=False,
|
|
231
|
+
allow_blank=True,
|
|
232
|
+
allow_null=True,
|
|
233
|
+
max_length=100,
|
|
234
|
+
help_text="""The address street number""",
|
|
235
|
+
)
|
|
236
|
+
address_line1 = serializers.CharField(
|
|
237
|
+
required=False,
|
|
238
|
+
allow_blank=True,
|
|
239
|
+
allow_null=True,
|
|
240
|
+
max_length=100,
|
|
241
|
+
help_text="""The address line with street number <br/>
|
|
242
|
+
**(required for shipment purchase)**
|
|
243
|
+
""",
|
|
244
|
+
)
|
|
245
|
+
address_line2 = serializers.CharField(
|
|
246
|
+
required=False,
|
|
247
|
+
allow_blank=True,
|
|
248
|
+
allow_null=True,
|
|
249
|
+
max_length=100,
|
|
250
|
+
help_text="The address line with suite number",
|
|
251
|
+
)
|
|
252
|
+
validate_location = serializers.BooleanField(
|
|
253
|
+
required=False,
|
|
254
|
+
allow_null=True,
|
|
255
|
+
default=False,
|
|
256
|
+
help_text="Indicate if the address should be validated",
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class Address(serializers.EntitySerializer, AddressData):
|
|
261
|
+
object_type = serializers.CharField(
|
|
262
|
+
default="address", help_text="Specifies the object type"
|
|
263
|
+
)
|
|
264
|
+
validation = AddressValidation(
|
|
265
|
+
required=False, allow_null=True, help_text="Specify address validation result"
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
class CommodityData(serializers.Serializer):
|
|
270
|
+
weight = serializers.FloatField(required=True, help_text="The commodity's weight")
|
|
271
|
+
weight_unit = serializers.ChoiceField(
|
|
272
|
+
required=True,
|
|
273
|
+
choices=WEIGHT_UNIT,
|
|
274
|
+
help_text="The commodity's weight unit",
|
|
275
|
+
)
|
|
276
|
+
title = serializers.CharField(
|
|
277
|
+
required=False,
|
|
278
|
+
allow_blank=True,
|
|
279
|
+
allow_null=True,
|
|
280
|
+
max_length=200,
|
|
281
|
+
help_text="A description of the commodity",
|
|
282
|
+
)
|
|
283
|
+
description = serializers.CharField(
|
|
284
|
+
required=False,
|
|
285
|
+
allow_blank=True,
|
|
286
|
+
allow_null=True,
|
|
287
|
+
max_length=200,
|
|
288
|
+
help_text="A description of the commodity",
|
|
289
|
+
)
|
|
290
|
+
quantity = serializers.IntegerField(
|
|
291
|
+
required=False,
|
|
292
|
+
default=1,
|
|
293
|
+
help_text="The commodity's quantity (number or item)",
|
|
294
|
+
)
|
|
295
|
+
sku = serializers.CharField(
|
|
296
|
+
required=False,
|
|
297
|
+
allow_blank=True,
|
|
298
|
+
allow_null=True,
|
|
299
|
+
max_length=100,
|
|
300
|
+
help_text="The commodity's sku number",
|
|
301
|
+
)
|
|
302
|
+
hs_code = serializers.CharField(
|
|
303
|
+
required=False,
|
|
304
|
+
allow_blank=True,
|
|
305
|
+
allow_null=True,
|
|
306
|
+
max_length=100,
|
|
307
|
+
help_text="The commodity's hs_code number",
|
|
308
|
+
)
|
|
309
|
+
value_amount = serializers.FloatField(
|
|
310
|
+
required=False,
|
|
311
|
+
allow_null=True,
|
|
312
|
+
help_text="The monetary value of the commodity",
|
|
313
|
+
)
|
|
314
|
+
value_currency = serializers.ChoiceField(
|
|
315
|
+
required=False,
|
|
316
|
+
allow_null=True,
|
|
317
|
+
choices=CURRENCIES,
|
|
318
|
+
help_text="The currency of the commodity value amount",
|
|
319
|
+
)
|
|
320
|
+
origin_country = serializers.ChoiceField(
|
|
321
|
+
required=False,
|
|
322
|
+
allow_null=True,
|
|
323
|
+
choices=COUNTRIES,
|
|
324
|
+
help_text="The origin or manufacture country",
|
|
325
|
+
)
|
|
326
|
+
product_url = serializers.CharField(
|
|
327
|
+
required=False,
|
|
328
|
+
allow_null=True,
|
|
329
|
+
help_text="The product url",
|
|
330
|
+
)
|
|
331
|
+
image_url = serializers.CharField(
|
|
332
|
+
required=False,
|
|
333
|
+
allow_null=True,
|
|
334
|
+
help_text="The image url",
|
|
335
|
+
)
|
|
336
|
+
product_id = serializers.CharField(
|
|
337
|
+
required=False,
|
|
338
|
+
allow_null=True,
|
|
339
|
+
help_text="The product id",
|
|
340
|
+
)
|
|
341
|
+
variant_id = serializers.CharField(
|
|
342
|
+
required=False,
|
|
343
|
+
allow_null=True,
|
|
344
|
+
help_text="The variant id",
|
|
345
|
+
)
|
|
346
|
+
parent_id = serializers.CharField(
|
|
347
|
+
required=False,
|
|
348
|
+
allow_null=True,
|
|
349
|
+
help_text="The id of the related order line item.",
|
|
350
|
+
)
|
|
351
|
+
metadata = serializers.PlainDictField(
|
|
352
|
+
required=False,
|
|
353
|
+
allow_null=True,
|
|
354
|
+
help_text="""<details>
|
|
355
|
+
<summary>Commodity user references metadata.</summary>
|
|
356
|
+
|
|
357
|
+
{
|
|
358
|
+
"part_number": "5218487281",
|
|
359
|
+
"reference1": "# ref 1",
|
|
360
|
+
"reference2": "# ref 2",
|
|
361
|
+
"reference3": "# ref 3",
|
|
362
|
+
...
|
|
363
|
+
}
|
|
364
|
+
</details>
|
|
365
|
+
""",
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
class Commodity(serializers.EntitySerializer, CommodityData):
|
|
370
|
+
object_type = serializers.CharField(
|
|
371
|
+
default="commodity", help_text="Specifies the object type"
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
@serializers.allow_model_id(
|
|
376
|
+
[
|
|
377
|
+
("items", "karrio.server.manager.models.Commodity"),
|
|
378
|
+
]
|
|
379
|
+
)
|
|
380
|
+
class ParcelData(validators.PresetSerializer):
|
|
381
|
+
weight = serializers.FloatField(required=True, help_text="The parcel's weight")
|
|
382
|
+
width = serializers.FloatField(
|
|
383
|
+
required=False, allow_null=True, help_text="The parcel's width"
|
|
384
|
+
)
|
|
385
|
+
height = serializers.FloatField(
|
|
386
|
+
required=False, allow_null=True, help_text="The parcel's height"
|
|
387
|
+
)
|
|
388
|
+
length = serializers.FloatField(
|
|
389
|
+
required=False, allow_null=True, help_text="The parcel's length"
|
|
390
|
+
)
|
|
391
|
+
packaging_type = serializers.CharField(
|
|
392
|
+
required=False,
|
|
393
|
+
allow_blank=True,
|
|
394
|
+
allow_null=True,
|
|
395
|
+
max_length=100,
|
|
396
|
+
help_text=f"""The parcel's packaging type.<br/>
|
|
397
|
+
**Note that the packaging is optional when using a package preset.**<br/>
|
|
398
|
+
values: <br/>
|
|
399
|
+
{' '.join([f'`{pkg}`' for pkg, _ in PACKAGING_UNIT])}<br/>
|
|
400
|
+
For carrier specific packaging types, please consult the reference.
|
|
401
|
+
""",
|
|
402
|
+
)
|
|
403
|
+
package_preset = serializers.CharField(
|
|
404
|
+
required=False,
|
|
405
|
+
allow_blank=True,
|
|
406
|
+
allow_null=True,
|
|
407
|
+
max_length=100,
|
|
408
|
+
help_text="""The parcel's package preset.<br/>
|
|
409
|
+
For carrier specific package presets, please consult the reference.
|
|
410
|
+
""",
|
|
411
|
+
)
|
|
412
|
+
description = serializers.CharField(
|
|
413
|
+
required=False,
|
|
414
|
+
allow_blank=True,
|
|
415
|
+
allow_null=True,
|
|
416
|
+
max_length=250,
|
|
417
|
+
help_text="The parcel's description",
|
|
418
|
+
)
|
|
419
|
+
content = serializers.CharField(
|
|
420
|
+
required=False,
|
|
421
|
+
allow_blank=True,
|
|
422
|
+
allow_null=True,
|
|
423
|
+
max_length=100,
|
|
424
|
+
help_text="The parcel's content description",
|
|
425
|
+
)
|
|
426
|
+
is_document = serializers.BooleanField(
|
|
427
|
+
required=False,
|
|
428
|
+
allow_null=True,
|
|
429
|
+
default=False,
|
|
430
|
+
help_text="Indicates if the parcel is composed of documents only",
|
|
431
|
+
)
|
|
432
|
+
weight_unit = serializers.ChoiceField(
|
|
433
|
+
required=True, choices=WEIGHT_UNIT, help_text="The parcel's weight unit"
|
|
434
|
+
)
|
|
435
|
+
dimension_unit = serializers.ChoiceField(
|
|
436
|
+
required=False,
|
|
437
|
+
allow_blank=False,
|
|
438
|
+
allow_null=True,
|
|
439
|
+
choices=DIMENSION_UNIT,
|
|
440
|
+
help_text="The parcel's dimension unit",
|
|
441
|
+
)
|
|
442
|
+
items = CommodityData(required=False, many=True, help_text="The parcel items.")
|
|
443
|
+
reference_number = serializers.CharField(
|
|
444
|
+
required=False,
|
|
445
|
+
allow_null=True,
|
|
446
|
+
max_length=100,
|
|
447
|
+
help_text="""The parcel reference number.<br/>
|
|
448
|
+
(can be used as tracking number for custom carriers)
|
|
449
|
+
""",
|
|
450
|
+
)
|
|
451
|
+
freight_class = serializers.CharField(
|
|
452
|
+
required=False,
|
|
453
|
+
allow_null=True,
|
|
454
|
+
max_length=6,
|
|
455
|
+
help_text="The parcel's freight class for pallet and freight shipments.",
|
|
456
|
+
)
|
|
457
|
+
options = serializers.PlainDictField(
|
|
458
|
+
required=False,
|
|
459
|
+
default={},
|
|
460
|
+
help_text="""<details>
|
|
461
|
+
<summary>Parcel specific options.</summary>
|
|
462
|
+
|
|
463
|
+
{
|
|
464
|
+
"insurance": "100.00",
|
|
465
|
+
"insured_by": "carrier",
|
|
466
|
+
}
|
|
467
|
+
</details>
|
|
468
|
+
""",
|
|
469
|
+
)
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
class Parcel(serializers.EntitySerializer, ParcelData):
|
|
473
|
+
object_type = serializers.CharField(
|
|
474
|
+
default="parcel", help_text="Specifies the object type"
|
|
475
|
+
)
|
|
476
|
+
items = Commodity(required=False, many=True, help_text="The parcel items.")
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
class Payment(serializers.Serializer):
|
|
480
|
+
paid_by = serializers.ChoiceField(
|
|
481
|
+
required=False,
|
|
482
|
+
choices=PAYMENT_TYPES,
|
|
483
|
+
default=PAYMENT_TYPES[0][0],
|
|
484
|
+
help_text="The payor type",
|
|
485
|
+
)
|
|
486
|
+
currency = serializers.ChoiceField(
|
|
487
|
+
required=False,
|
|
488
|
+
allow_blank=True,
|
|
489
|
+
allow_null=True,
|
|
490
|
+
choices=CURRENCIES,
|
|
491
|
+
help_text="The payment amount currency",
|
|
492
|
+
)
|
|
493
|
+
account_number = serializers.CharField(
|
|
494
|
+
required=False,
|
|
495
|
+
allow_blank=True,
|
|
496
|
+
allow_null=True,
|
|
497
|
+
help_text="The payor account number",
|
|
498
|
+
)
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
class Duty(serializers.Serializer):
|
|
502
|
+
paid_by = serializers.ChoiceField(
|
|
503
|
+
required=False,
|
|
504
|
+
choices=PAYMENT_TYPES,
|
|
505
|
+
allow_blank=True,
|
|
506
|
+
allow_null=True,
|
|
507
|
+
help_text="The duty payer",
|
|
508
|
+
)
|
|
509
|
+
currency = serializers.ChoiceField(
|
|
510
|
+
required=False,
|
|
511
|
+
choices=CURRENCIES,
|
|
512
|
+
allow_blank=True,
|
|
513
|
+
allow_null=True,
|
|
514
|
+
help_text="The declared value currency",
|
|
515
|
+
)
|
|
516
|
+
declared_value = serializers.FloatField(
|
|
517
|
+
required=False, allow_null=True, help_text="The package declared value"
|
|
518
|
+
)
|
|
519
|
+
account_number = serializers.CharField(
|
|
520
|
+
required=False,
|
|
521
|
+
allow_blank=True,
|
|
522
|
+
allow_null=True,
|
|
523
|
+
help_text="The duty payment account number",
|
|
524
|
+
)
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
@serializers.allow_model_id(
|
|
528
|
+
[
|
|
529
|
+
("commodities", "karrio.server.manager.models.Commodity"),
|
|
530
|
+
("duty_billing_address", "karrio.server.manager.models.Address"),
|
|
531
|
+
]
|
|
532
|
+
)
|
|
533
|
+
class CustomsData(serializers.Serializer):
|
|
534
|
+
commodities = CommodityData(
|
|
535
|
+
many=True, allow_empty=False, help_text="The parcel content items"
|
|
536
|
+
)
|
|
537
|
+
duty = Duty(
|
|
538
|
+
required=False,
|
|
539
|
+
allow_null=True,
|
|
540
|
+
help_text="""The payment details.<br/>
|
|
541
|
+
**Note that this is required for a Dutiable parcel shipped internationally.**
|
|
542
|
+
""",
|
|
543
|
+
)
|
|
544
|
+
duty_billing_address = AddressData(
|
|
545
|
+
required=False, allow_null=True, help_text="The duty payor address."
|
|
546
|
+
)
|
|
547
|
+
content_type = serializers.ChoiceField(
|
|
548
|
+
required=False, choices=CUSTOMS_CONTENT_TYPE, allow_blank=True, allow_null=True
|
|
549
|
+
)
|
|
550
|
+
content_description = serializers.CharField(
|
|
551
|
+
required=False, allow_blank=True, allow_null=True
|
|
552
|
+
)
|
|
553
|
+
incoterm = serializers.ChoiceField(
|
|
554
|
+
required=False,
|
|
555
|
+
allow_null=True,
|
|
556
|
+
choices=INCOTERMS,
|
|
557
|
+
help_text="The customs 'term of trade' also known as 'incoterm'",
|
|
558
|
+
)
|
|
559
|
+
invoice = serializers.CharField(
|
|
560
|
+
required=False,
|
|
561
|
+
allow_null=True,
|
|
562
|
+
allow_blank=True,
|
|
563
|
+
max_length=50,
|
|
564
|
+
help_text="The invoice reference number",
|
|
565
|
+
)
|
|
566
|
+
invoice_date = serializers.CharField(
|
|
567
|
+
required=False,
|
|
568
|
+
allow_null=True,
|
|
569
|
+
allow_blank=True,
|
|
570
|
+
validators=[validators.valid_date_format("invoice_date")],
|
|
571
|
+
help_text="""The invoice date.<br/>
|
|
572
|
+
Date Format: `YYYY-MM-DD`
|
|
573
|
+
""",
|
|
574
|
+
)
|
|
575
|
+
commercial_invoice = serializers.BooleanField(
|
|
576
|
+
required=False,
|
|
577
|
+
allow_null=True,
|
|
578
|
+
help_text="Indicates if the shipment is commercial",
|
|
579
|
+
)
|
|
580
|
+
certify = serializers.BooleanField(
|
|
581
|
+
required=False,
|
|
582
|
+
allow_null=True,
|
|
583
|
+
help_text="Indicate that signer certified confirmed all",
|
|
584
|
+
)
|
|
585
|
+
signer = serializers.CharField(
|
|
586
|
+
required=False, max_length=50, allow_blank=True, allow_null=True
|
|
587
|
+
)
|
|
588
|
+
options = serializers.PlainDictField(
|
|
589
|
+
required=False,
|
|
590
|
+
default={},
|
|
591
|
+
help_text="""<details>
|
|
592
|
+
<summary>Customs identification options.</summary>
|
|
593
|
+
|
|
594
|
+
{
|
|
595
|
+
"aes": "5218487281",
|
|
596
|
+
"eel_pfc": "5218487281",
|
|
597
|
+
"license_number": "5218487281",
|
|
598
|
+
"certificate_number": "5218487281",
|
|
599
|
+
"nip_number": "5218487281",
|
|
600
|
+
"eori_number": "5218487281",
|
|
601
|
+
"vat_registration_number": "5218487281",
|
|
602
|
+
}
|
|
603
|
+
</details>
|
|
604
|
+
""",
|
|
605
|
+
)
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
class Customs(serializers.EntitySerializer, CustomsData):
|
|
609
|
+
object_type = serializers.CharField(
|
|
610
|
+
default="customs_info", help_text="Specifies the object type"
|
|
611
|
+
)
|
|
612
|
+
commodities = Commodity(
|
|
613
|
+
required=False, many=True, help_text="The parcel content items"
|
|
614
|
+
)
|
|
615
|
+
duty_billing_address = Address(
|
|
616
|
+
required=False, allow_null=True, help_text="The duty payor address."
|
|
617
|
+
)
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
class Charge(serializers.Serializer):
|
|
621
|
+
name = serializers.CharField(
|
|
622
|
+
required=False,
|
|
623
|
+
allow_blank=True,
|
|
624
|
+
allow_null=True,
|
|
625
|
+
help_text="The charge description",
|
|
626
|
+
)
|
|
627
|
+
amount = serializers.FloatField(
|
|
628
|
+
required=False, allow_null=True, help_text="The charge monetary value"
|
|
629
|
+
)
|
|
630
|
+
currency = serializers.CharField(
|
|
631
|
+
required=False,
|
|
632
|
+
allow_blank=True,
|
|
633
|
+
allow_null=True,
|
|
634
|
+
help_text="The charge amount currency",
|
|
635
|
+
)
|
|
636
|
+
id = serializers.CharField(
|
|
637
|
+
required=False,
|
|
638
|
+
allow_blank=True,
|
|
639
|
+
allow_null=True,
|
|
640
|
+
help_text="A surcharge id",
|
|
641
|
+
)
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
@serializers.allow_model_id(
|
|
645
|
+
[
|
|
646
|
+
("shipper", "karrio.server.manager.models.Address"),
|
|
647
|
+
("recipient", "karrio.server.manager.models.Address"),
|
|
648
|
+
("parcels", "karrio.server.manager.models.Parcel"),
|
|
649
|
+
]
|
|
650
|
+
)
|
|
651
|
+
class RateRequest(validators.OptionDefaultSerializer):
|
|
652
|
+
shipper = AddressData(
|
|
653
|
+
required=True,
|
|
654
|
+
help_text="""The address of the party<br/>
|
|
655
|
+
Origin address (ship from) for the **shipper**<br/>
|
|
656
|
+
Destination address (ship to) for the **recipient**
|
|
657
|
+
""",
|
|
658
|
+
)
|
|
659
|
+
recipient = AddressData(
|
|
660
|
+
required=True,
|
|
661
|
+
help_text="""The address of the party<br/>
|
|
662
|
+
Origin address (ship from) for the **shipper**<br/>
|
|
663
|
+
Destination address (ship to) for the **recipient**
|
|
664
|
+
""",
|
|
665
|
+
)
|
|
666
|
+
parcels = ParcelData(
|
|
667
|
+
many=True,
|
|
668
|
+
allow_empty=False,
|
|
669
|
+
help_text="The shipment's parcels",
|
|
670
|
+
)
|
|
671
|
+
services = serializers.StringListField(
|
|
672
|
+
required=False,
|
|
673
|
+
allow_null=True,
|
|
674
|
+
default=[],
|
|
675
|
+
help_text="""The requested carrier service for the shipment.<br/>
|
|
676
|
+
Please consult the reference for specific carriers services.<br/>
|
|
677
|
+
Note that this is a list because on a Multi-carrier rate request you could specify a service per carrier.
|
|
678
|
+
""",
|
|
679
|
+
)
|
|
680
|
+
options = serializers.PlainDictField(
|
|
681
|
+
required=False,
|
|
682
|
+
default={},
|
|
683
|
+
help_text="""<details>
|
|
684
|
+
<summary>The options available for the shipment.</summary>
|
|
685
|
+
|
|
686
|
+
{
|
|
687
|
+
"currency": "USD",
|
|
688
|
+
"insurance": 100.00,
|
|
689
|
+
"cash_on_delivery": 30.00,
|
|
690
|
+
"dangerous_good": true,
|
|
691
|
+
"declared_value": 150.00,
|
|
692
|
+
"sms_notification": true,
|
|
693
|
+
"email_notification": true,
|
|
694
|
+
"email_notification_to": "shipper@mail.com",
|
|
695
|
+
"hold_at_location": true,
|
|
696
|
+
"paperless_trade": true,
|
|
697
|
+
"preferred_service": "fedex_express_saver",
|
|
698
|
+
"shipment_date": "2020-01-01", # TODO: deprecate
|
|
699
|
+
"shipping_date": "2020-01-01T00:00",
|
|
700
|
+
"shipment_note": "This is a shipment note",
|
|
701
|
+
"signature_confirmation": true,
|
|
702
|
+
"saturday_delivery": true,
|
|
703
|
+
"is_return": true,
|
|
704
|
+
"shipper_instructions": "This is a shipper instruction",
|
|
705
|
+
"recipient_instructions": "This is a recipient instruction",
|
|
706
|
+
"doc_files": [
|
|
707
|
+
{
|
|
708
|
+
"doc_type": "commercial_invoice",
|
|
709
|
+
"doc_file": "base64 encoded file",
|
|
710
|
+
"doc_name": "commercial_invoice.pdf",
|
|
711
|
+
"doc_format": "pdf",
|
|
712
|
+
}
|
|
713
|
+
],
|
|
714
|
+
"doc_references": [
|
|
715
|
+
{
|
|
716
|
+
"doc_id": "123456789",
|
|
717
|
+
"doc_type": "commercial_invoice",
|
|
718
|
+
}
|
|
719
|
+
],
|
|
720
|
+
}
|
|
721
|
+
</details>
|
|
722
|
+
""",
|
|
723
|
+
)
|
|
724
|
+
reference = serializers.CharField(
|
|
725
|
+
required=False,
|
|
726
|
+
allow_blank=True,
|
|
727
|
+
allow_null=True,
|
|
728
|
+
help_text="The shipment reference",
|
|
729
|
+
)
|
|
730
|
+
carrier_ids = serializers.StringListField(
|
|
731
|
+
required=False,
|
|
732
|
+
allow_null=True,
|
|
733
|
+
default=[],
|
|
734
|
+
help_text="The list of configured carriers you wish to get rates from.",
|
|
735
|
+
)
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
class TrackingInfo(serializers.Serializer):
|
|
739
|
+
carrier_tracking_link = serializers.CharField(
|
|
740
|
+
required=False, allow_null=True, help_text="The carrier tracking link"
|
|
741
|
+
)
|
|
742
|
+
customer_name = serializers.CharField(
|
|
743
|
+
required=False, allow_null=True, help_text="The customer name"
|
|
744
|
+
)
|
|
745
|
+
expected_delivery = serializers.CharField(
|
|
746
|
+
required=False, allow_null=True, help_text="The expected delivery date"
|
|
747
|
+
)
|
|
748
|
+
note = serializers.CharField(
|
|
749
|
+
required=False, allow_null=True, help_text="A tracking note"
|
|
750
|
+
)
|
|
751
|
+
order_date = serializers.CharField(
|
|
752
|
+
required=False, allow_null=True, help_text="The package order date"
|
|
753
|
+
)
|
|
754
|
+
order_id = serializers.CharField(
|
|
755
|
+
required=False, allow_null=True, help_text="The package order id or number"
|
|
756
|
+
)
|
|
757
|
+
package_weight = serializers.CharField(
|
|
758
|
+
required=False, allow_null=True, help_text="The package weight"
|
|
759
|
+
)
|
|
760
|
+
package_weight_unit = serializers.CharField(
|
|
761
|
+
required=False, allow_null=True, help_text="The package weight unit"
|
|
762
|
+
)
|
|
763
|
+
shipment_package_count = serializers.CharField(
|
|
764
|
+
required=False, allow_null=True, help_text="The package count"
|
|
765
|
+
)
|
|
766
|
+
shipment_pickup_date = serializers.CharField(
|
|
767
|
+
required=False, allow_null=True, help_text="The shipment pickup date"
|
|
768
|
+
)
|
|
769
|
+
shipment_delivery_date = serializers.CharField(
|
|
770
|
+
required=False, allow_null=True, help_text="The shipment delivery date"
|
|
771
|
+
)
|
|
772
|
+
shipment_service = serializers.CharField(
|
|
773
|
+
required=False, allow_null=True, help_text="The shipment service"
|
|
774
|
+
)
|
|
775
|
+
shipment_origin_country = serializers.CharField(
|
|
776
|
+
required=False, allow_null=True, help_text="The shipment origin country"
|
|
777
|
+
)
|
|
778
|
+
shipment_origin_postal_code = serializers.CharField(
|
|
779
|
+
required=False, allow_null=True, help_text="The shipment origin postal code"
|
|
780
|
+
)
|
|
781
|
+
shipment_destination_country = serializers.CharField(
|
|
782
|
+
required=False, allow_null=True, help_text="The shipment destination country"
|
|
783
|
+
)
|
|
784
|
+
shipment_destination_postal_code = serializers.CharField(
|
|
785
|
+
required=False,
|
|
786
|
+
allow_null=True,
|
|
787
|
+
help_text="The shipment destination postal code",
|
|
788
|
+
)
|
|
789
|
+
shipping_date = serializers.CharField(
|
|
790
|
+
required=False, allow_null=True, help_text="The shipping date"
|
|
791
|
+
)
|
|
792
|
+
signed_by = serializers.CharField(
|
|
793
|
+
required=False,
|
|
794
|
+
allow_null=True,
|
|
795
|
+
help_text="The person who signed for the package",
|
|
796
|
+
)
|
|
797
|
+
source = serializers.CharField(
|
|
798
|
+
required=False, allow_null=True, help_text="The tracker source"
|
|
799
|
+
)
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
class TrackingData(serializers.Serializer):
|
|
803
|
+
tracking_number = serializers.CharField(
|
|
804
|
+
required=True,
|
|
805
|
+
help_text="The package tracking number",
|
|
806
|
+
)
|
|
807
|
+
carrier_name = serializers.ChoiceField(
|
|
808
|
+
choices=dataunits.NON_HUBS_CARRIERS,
|
|
809
|
+
required=True,
|
|
810
|
+
help_text="The tracking carrier",
|
|
811
|
+
)
|
|
812
|
+
account_number = serializers.CharField(
|
|
813
|
+
required=False,
|
|
814
|
+
allow_blank=True,
|
|
815
|
+
allow_null=True,
|
|
816
|
+
help_text="The shipper account number",
|
|
817
|
+
)
|
|
818
|
+
reference = serializers.CharField(
|
|
819
|
+
required=False,
|
|
820
|
+
allow_blank=True,
|
|
821
|
+
allow_null=True,
|
|
822
|
+
help_text="The shipment reference",
|
|
823
|
+
)
|
|
824
|
+
info = TrackingInfo(
|
|
825
|
+
required=False,
|
|
826
|
+
allow_null=True,
|
|
827
|
+
help_text="The package and shipment tracking details",
|
|
828
|
+
)
|
|
829
|
+
metadata = serializers.PlainDictField(
|
|
830
|
+
required=False, default={}, help_text="The carrier user metadata."
|
|
831
|
+
)
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
class TrackingRequest(serializers.Serializer):
|
|
835
|
+
tracking_numbers = serializers.StringListField(
|
|
836
|
+
required=True, help_text="a list of tracking numbers to fetch."
|
|
837
|
+
)
|
|
838
|
+
account_number = serializers.CharField(
|
|
839
|
+
required=False,
|
|
840
|
+
allow_blank=True,
|
|
841
|
+
allow_null=True,
|
|
842
|
+
help_text="The shipper account number",
|
|
843
|
+
)
|
|
844
|
+
reference = serializers.CharField(
|
|
845
|
+
required=False,
|
|
846
|
+
allow_blank=True,
|
|
847
|
+
allow_null=True,
|
|
848
|
+
help_text="The shipment reference",
|
|
849
|
+
)
|
|
850
|
+
options = serializers.PlainDictField(
|
|
851
|
+
required=False,
|
|
852
|
+
default={},
|
|
853
|
+
help_text="additional tracking options",
|
|
854
|
+
)
|
|
855
|
+
info = TrackingInfo(
|
|
856
|
+
required=False,
|
|
857
|
+
allow_null=True,
|
|
858
|
+
help_text="The package and shipment tracking details",
|
|
859
|
+
)
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
@serializers.allow_model_id(
|
|
863
|
+
[
|
|
864
|
+
("address", "karrio.server.manager.models.Address"),
|
|
865
|
+
("parcels", "karrio.server.manager.models.Parcel"),
|
|
866
|
+
]
|
|
867
|
+
)
|
|
868
|
+
class PickupRequest(serializers.Serializer):
|
|
869
|
+
pickup_date = serializers.CharField(
|
|
870
|
+
required=True,
|
|
871
|
+
validators=[validators.valid_date_format("pickup_date")],
|
|
872
|
+
help_text="""The expected pickup date.<br/>
|
|
873
|
+
Date Format: `YYYY-MM-DD`
|
|
874
|
+
""",
|
|
875
|
+
)
|
|
876
|
+
address = AddressData(required=True, help_text="The pickup address")
|
|
877
|
+
parcels = ParcelData(
|
|
878
|
+
many=True,
|
|
879
|
+
allow_empty=False,
|
|
880
|
+
help_text="The shipment parcels to pickup.",
|
|
881
|
+
)
|
|
882
|
+
ready_time = serializers.CharField(
|
|
883
|
+
required=True,
|
|
884
|
+
validators=[validators.valid_time_format("ready_time")],
|
|
885
|
+
help_text="""The ready time for pickup.<br/>
|
|
886
|
+
Time Format: `HH:MM`
|
|
887
|
+
""",
|
|
888
|
+
)
|
|
889
|
+
closing_time = serializers.CharField(
|
|
890
|
+
required=True,
|
|
891
|
+
validators=[validators.valid_time_format("closing_time")],
|
|
892
|
+
help_text="""The closing or late time of the pickup.<br/>
|
|
893
|
+
Time Format: `HH:MM`
|
|
894
|
+
""",
|
|
895
|
+
)
|
|
896
|
+
instruction = serializers.CharField(
|
|
897
|
+
required=False,
|
|
898
|
+
allow_blank=True,
|
|
899
|
+
allow_null=True,
|
|
900
|
+
max_length=50,
|
|
901
|
+
help_text="""The pickup instruction.<br/>
|
|
902
|
+
eg: Handle with care.
|
|
903
|
+
""",
|
|
904
|
+
)
|
|
905
|
+
package_location = serializers.CharField(
|
|
906
|
+
required=False,
|
|
907
|
+
allow_blank=True,
|
|
908
|
+
allow_null=True,
|
|
909
|
+
max_length=50,
|
|
910
|
+
help_text="""The package(s) location.<br/>
|
|
911
|
+
eg: Behind the entrance door.
|
|
912
|
+
""",
|
|
913
|
+
)
|
|
914
|
+
options = serializers.PlainDictField(
|
|
915
|
+
required=False,
|
|
916
|
+
allow_null=True,
|
|
917
|
+
help_text="Advanced carrier specific pickup options",
|
|
918
|
+
)
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
@serializers.allow_model_id(
|
|
922
|
+
[
|
|
923
|
+
("address", "karrio.server.manager.models.Address"),
|
|
924
|
+
("parcels", "karrio.server.manager.models.Parcel"),
|
|
925
|
+
]
|
|
926
|
+
)
|
|
927
|
+
class PickupUpdateRequest(serializers.Serializer):
|
|
928
|
+
pickup_date = serializers.CharField(
|
|
929
|
+
required=True,
|
|
930
|
+
help_text="""The expected pickup date.<br/>
|
|
931
|
+
Date Format: `YYYY-MM-DD`
|
|
932
|
+
""",
|
|
933
|
+
)
|
|
934
|
+
address = Address(required=True, help_text="The pickup address")
|
|
935
|
+
parcels = Parcel(
|
|
936
|
+
many=True,
|
|
937
|
+
allow_empty=False,
|
|
938
|
+
help_text="The shipment parcels to pickup.",
|
|
939
|
+
)
|
|
940
|
+
confirmation_number = serializers.CharField(
|
|
941
|
+
required=True, help_text="pickup identification number"
|
|
942
|
+
)
|
|
943
|
+
ready_time = serializers.CharField(
|
|
944
|
+
required=True,
|
|
945
|
+
validators=[validators.valid_time_format("ready_time")],
|
|
946
|
+
help_text="""The ready time for pickup.
|
|
947
|
+
Time Format: `HH:MM`
|
|
948
|
+
""",
|
|
949
|
+
)
|
|
950
|
+
closing_time = serializers.CharField(
|
|
951
|
+
required=True,
|
|
952
|
+
validators=[validators.valid_time_format("closing_time")],
|
|
953
|
+
help_text="""The closing or late time of the pickup.<br/>
|
|
954
|
+
Time Format: `HH:MM`
|
|
955
|
+
""",
|
|
956
|
+
)
|
|
957
|
+
instruction = serializers.CharField(
|
|
958
|
+
required=False,
|
|
959
|
+
allow_blank=True,
|
|
960
|
+
allow_null=True,
|
|
961
|
+
max_length=50,
|
|
962
|
+
help_text="""The pickup instruction.<br/>
|
|
963
|
+
eg: Handle with care.
|
|
964
|
+
""",
|
|
965
|
+
)
|
|
966
|
+
package_location = serializers.CharField(
|
|
967
|
+
required=False,
|
|
968
|
+
allow_blank=True,
|
|
969
|
+
allow_null=True,
|
|
970
|
+
max_length=50,
|
|
971
|
+
help_text="""The package(s) location.<br/>
|
|
972
|
+
eg: Behind the entrance door.
|
|
973
|
+
""",
|
|
974
|
+
)
|
|
975
|
+
options = serializers.PlainDictField(
|
|
976
|
+
required=False,
|
|
977
|
+
allow_null=True,
|
|
978
|
+
help_text="Advanced carrier specific pickup options",
|
|
979
|
+
)
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
class PickupDetails(serializers.Serializer):
|
|
983
|
+
id = serializers.CharField(required=False, help_text="A unique pickup identifier")
|
|
984
|
+
object_type = serializers.CharField(
|
|
985
|
+
default="pickup", help_text="Specifies the object type"
|
|
986
|
+
)
|
|
987
|
+
carrier_name = serializers.CharField(required=True, help_text="The pickup carrier")
|
|
988
|
+
carrier_id = serializers.CharField(
|
|
989
|
+
required=True, help_text="The pickup carrier configured name"
|
|
990
|
+
)
|
|
991
|
+
confirmation_number = serializers.CharField(
|
|
992
|
+
required=True, help_text="The pickup confirmation identifier"
|
|
993
|
+
)
|
|
994
|
+
pickup_date = serializers.CharField(
|
|
995
|
+
required=False, allow_null=True, help_text="The pickup date"
|
|
996
|
+
)
|
|
997
|
+
pickup_charge = Charge(
|
|
998
|
+
required=False, allow_null=True, help_text="The pickup cost details"
|
|
999
|
+
)
|
|
1000
|
+
ready_time = serializers.CharField(
|
|
1001
|
+
required=False, allow_null=True, help_text="The pickup expected ready time"
|
|
1002
|
+
)
|
|
1003
|
+
closing_time = serializers.CharField(
|
|
1004
|
+
required=False,
|
|
1005
|
+
allow_null=True,
|
|
1006
|
+
help_text="The pickup expected closing or late time",
|
|
1007
|
+
)
|
|
1008
|
+
metadata = serializers.PlainDictField(
|
|
1009
|
+
required=False, default={}, help_text="User metadata for the pickup"
|
|
1010
|
+
)
|
|
1011
|
+
meta = serializers.PlainDictField(
|
|
1012
|
+
required=False, allow_null=True, help_text="provider specific metadata"
|
|
1013
|
+
)
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
class Pickup(PickupDetails, PickupRequest):
|
|
1017
|
+
address = Address(required=True, help_text="The pickup address")
|
|
1018
|
+
parcels = Parcel(
|
|
1019
|
+
many=True,
|
|
1020
|
+
allow_empty=False,
|
|
1021
|
+
help_text="The shipment parcels to pickup.",
|
|
1022
|
+
)
|
|
1023
|
+
test_mode = serializers.BooleanField(
|
|
1024
|
+
required=True,
|
|
1025
|
+
help_text="Specified whether it was created with a carrier in test mode",
|
|
1026
|
+
)
|
|
1027
|
+
|
|
1028
|
+
|
|
1029
|
+
@serializers.allow_model_id(
|
|
1030
|
+
[
|
|
1031
|
+
("address", "karrio.server.manager.models.Address"),
|
|
1032
|
+
]
|
|
1033
|
+
)
|
|
1034
|
+
class PickupCancelRequest(serializers.Serializer):
|
|
1035
|
+
confirmation_number = serializers.CharField(
|
|
1036
|
+
required=True, help_text="The pickup confirmation identifier"
|
|
1037
|
+
)
|
|
1038
|
+
address = AddressData(required=False, help_text="The pickup address")
|
|
1039
|
+
pickup_date = serializers.CharField(
|
|
1040
|
+
required=False,
|
|
1041
|
+
allow_null=True,
|
|
1042
|
+
validators=[validators.valid_date_format("pickup_date")],
|
|
1043
|
+
help_text="""The pickup date.<br/>
|
|
1044
|
+
Date Format: `YYYY-MM-DD`
|
|
1045
|
+
""",
|
|
1046
|
+
)
|
|
1047
|
+
reason = serializers.CharField(
|
|
1048
|
+
required=False, help_text="The reason of the pickup cancellation"
|
|
1049
|
+
)
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
class Images(serializers.Serializer):
|
|
1053
|
+
delivery_image = serializers.CharField(
|
|
1054
|
+
required=False,
|
|
1055
|
+
allow_blank=True,
|
|
1056
|
+
allow_null=True,
|
|
1057
|
+
help_text="A delivery image in base64 string",
|
|
1058
|
+
)
|
|
1059
|
+
signature_image = serializers.CharField(
|
|
1060
|
+
required=False,
|
|
1061
|
+
allow_blank=True,
|
|
1062
|
+
allow_null=True,
|
|
1063
|
+
help_text="A signature image in base64 string",
|
|
1064
|
+
)
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
class TrackingEvent(serializers.Serializer):
|
|
1068
|
+
date = serializers.CharField(
|
|
1069
|
+
required=False, help_text="The tracking event's date. Format: `YYYY-MM-DD`"
|
|
1070
|
+
)
|
|
1071
|
+
description = serializers.CharField(
|
|
1072
|
+
required=False, help_text="The tracking event's description"
|
|
1073
|
+
)
|
|
1074
|
+
location = serializers.CharField(
|
|
1075
|
+
required=False, help_text="The tracking event's location"
|
|
1076
|
+
)
|
|
1077
|
+
code = serializers.CharField(
|
|
1078
|
+
required=False,
|
|
1079
|
+
allow_blank=True,
|
|
1080
|
+
allow_null=True,
|
|
1081
|
+
help_text="The tracking event's code",
|
|
1082
|
+
)
|
|
1083
|
+
time = serializers.CharField(
|
|
1084
|
+
required=False,
|
|
1085
|
+
allow_blank=True,
|
|
1086
|
+
allow_null=True,
|
|
1087
|
+
help_text="The tracking event's time. Format: `HH:MM AM/PM`",
|
|
1088
|
+
)
|
|
1089
|
+
latitude = serializers.FloatField(
|
|
1090
|
+
required=False,
|
|
1091
|
+
allow_null=True,
|
|
1092
|
+
help_text="""The tracking event's latitude.""",
|
|
1093
|
+
)
|
|
1094
|
+
longitude = serializers.FloatField(
|
|
1095
|
+
required=False,
|
|
1096
|
+
allow_null=True,
|
|
1097
|
+
help_text="""The tracking event's longitude.""",
|
|
1098
|
+
)
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
class TrackingDetails(serializers.Serializer):
|
|
1102
|
+
carrier_name = serializers.CharField(
|
|
1103
|
+
required=True, help_text="The tracking carrier"
|
|
1104
|
+
)
|
|
1105
|
+
carrier_id = serializers.CharField(
|
|
1106
|
+
required=True, help_text="The tracking carrier configured identifier"
|
|
1107
|
+
)
|
|
1108
|
+
tracking_number = serializers.CharField(
|
|
1109
|
+
required=True, help_text="The shipment tracking number"
|
|
1110
|
+
)
|
|
1111
|
+
info = TrackingInfo(
|
|
1112
|
+
required=False,
|
|
1113
|
+
allow_null=True,
|
|
1114
|
+
default={},
|
|
1115
|
+
help_text="The package and shipment tracking details",
|
|
1116
|
+
)
|
|
1117
|
+
events = TrackingEvent(
|
|
1118
|
+
many=True,
|
|
1119
|
+
required=False,
|
|
1120
|
+
allow_null=True,
|
|
1121
|
+
allow_empty=True,
|
|
1122
|
+
help_text="The tracking details events",
|
|
1123
|
+
)
|
|
1124
|
+
delivered = serializers.BooleanField(
|
|
1125
|
+
required=False, help_text="Specified whether the related shipment was delivered"
|
|
1126
|
+
)
|
|
1127
|
+
test_mode = serializers.BooleanField(
|
|
1128
|
+
required=True,
|
|
1129
|
+
help_text="Specified whether the object was created with a carrier in test mode",
|
|
1130
|
+
)
|
|
1131
|
+
status = serializers.ChoiceField(
|
|
1132
|
+
required=False,
|
|
1133
|
+
default=TRACKER_STATUS[0][0],
|
|
1134
|
+
choices=TRACKER_STATUS,
|
|
1135
|
+
help_text="The current tracking status",
|
|
1136
|
+
)
|
|
1137
|
+
estimated_delivery = serializers.CharField(
|
|
1138
|
+
required=False,
|
|
1139
|
+
help_text="The delivery estimated date",
|
|
1140
|
+
)
|
|
1141
|
+
meta = serializers.PlainDictField(
|
|
1142
|
+
required=False, allow_null=True, help_text="provider specific metadata"
|
|
1143
|
+
)
|
|
1144
|
+
images = Images(
|
|
1145
|
+
required=False,
|
|
1146
|
+
allow_null=True,
|
|
1147
|
+
help_text="The tracker documents",
|
|
1148
|
+
)
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
class TrackerDetails(serializers.EntitySerializer, TrackingDetails):
|
|
1152
|
+
object_type = serializers.CharField(
|
|
1153
|
+
default="tracker", help_text="Specifies the object type"
|
|
1154
|
+
)
|
|
1155
|
+
metadata = serializers.PlainDictField(
|
|
1156
|
+
required=False, default={}, help_text="User metadata for the tracker"
|
|
1157
|
+
)
|
|
1158
|
+
messages = Message(
|
|
1159
|
+
required=False,
|
|
1160
|
+
many=True,
|
|
1161
|
+
default=[],
|
|
1162
|
+
help_text="The list of note or warning messages",
|
|
1163
|
+
)
|
|
1164
|
+
|
|
1165
|
+
|
|
1166
|
+
class TrackingStatus(TrackerDetails):
|
|
1167
|
+
images = None
|
|
1168
|
+
delivery_image_url = serializers.URLField(
|
|
1169
|
+
required=False,
|
|
1170
|
+
allow_blank=True,
|
|
1171
|
+
allow_null=True,
|
|
1172
|
+
help_text="The shipment invoice URL",
|
|
1173
|
+
)
|
|
1174
|
+
signature_image_url = serializers.URLField(
|
|
1175
|
+
required=False,
|
|
1176
|
+
allow_blank=True,
|
|
1177
|
+
allow_null=True,
|
|
1178
|
+
help_text="The shipment invoice URL",
|
|
1179
|
+
)
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
class Documents(serializers.Serializer):
|
|
1183
|
+
label = serializers.CharField(
|
|
1184
|
+
required=False,
|
|
1185
|
+
allow_blank=True,
|
|
1186
|
+
allow_null=True,
|
|
1187
|
+
help_text="A shipping label in base64 string",
|
|
1188
|
+
)
|
|
1189
|
+
invoice = serializers.CharField(
|
|
1190
|
+
required=False,
|
|
1191
|
+
allow_blank=True,
|
|
1192
|
+
allow_null=True,
|
|
1193
|
+
help_text="A shipping invoice in base64 string",
|
|
1194
|
+
)
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
class Rate(serializers.EntitySerializer):
|
|
1198
|
+
object_type = serializers.CharField(
|
|
1199
|
+
default="rate", help_text="Specifies the object type"
|
|
1200
|
+
)
|
|
1201
|
+
carrier_name = serializers.CharField(required=True, help_text="The rate's carrier")
|
|
1202
|
+
carrier_id = serializers.CharField(
|
|
1203
|
+
required=True, help_text="The targeted carrier's name (unique identifier)"
|
|
1204
|
+
)
|
|
1205
|
+
currency = serializers.CharField(
|
|
1206
|
+
required=False, help_text="The rate monetary values currency code"
|
|
1207
|
+
)
|
|
1208
|
+
service = serializers.CharField(
|
|
1209
|
+
required=False,
|
|
1210
|
+
allow_blank=True,
|
|
1211
|
+
allow_null=True,
|
|
1212
|
+
help_text="The carrier's rate (quote) service",
|
|
1213
|
+
)
|
|
1214
|
+
total_charge = serializers.FloatField(
|
|
1215
|
+
default=0.0,
|
|
1216
|
+
help_text="""The rate's monetary amount of the total charge.<br/>
|
|
1217
|
+
This is the gross amount of the rate after adding the additional charges
|
|
1218
|
+
""",
|
|
1219
|
+
)
|
|
1220
|
+
transit_days = serializers.IntegerField(
|
|
1221
|
+
required=False, allow_null=True, help_text="The estimated delivery transit days"
|
|
1222
|
+
)
|
|
1223
|
+
extra_charges = Charge(
|
|
1224
|
+
many=True,
|
|
1225
|
+
allow_empty=True,
|
|
1226
|
+
default=[],
|
|
1227
|
+
help_text="list of the rate's additional charges",
|
|
1228
|
+
)
|
|
1229
|
+
estimated_delivery = serializers.CharField(
|
|
1230
|
+
required=False,
|
|
1231
|
+
allow_null=True,
|
|
1232
|
+
help_text="The delivery estimated date",
|
|
1233
|
+
)
|
|
1234
|
+
meta = serializers.PlainDictField(
|
|
1235
|
+
required=False, allow_null=True, help_text="provider specific metadata"
|
|
1236
|
+
)
|
|
1237
|
+
test_mode = serializers.BooleanField(
|
|
1238
|
+
required=True,
|
|
1239
|
+
help_text="Specified whether it was created with a carrier in test mode",
|
|
1240
|
+
)
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
@serializers.allow_model_id(
|
|
1244
|
+
[
|
|
1245
|
+
("shipper", "karrio.server.manager.models.Address"),
|
|
1246
|
+
("recipient", "karrio.server.manager.models.Address"),
|
|
1247
|
+
("parcels", "karrio.server.manager.models.Parcel"),
|
|
1248
|
+
("customs", "karrio.server.manager.models.Customs"),
|
|
1249
|
+
("return_address", "karrio.server.manager.models.Address"),
|
|
1250
|
+
("billing_address", "karrio.server.manager.models.Address"),
|
|
1251
|
+
]
|
|
1252
|
+
)
|
|
1253
|
+
class ShippingData(validators.OptionDefaultSerializer):
|
|
1254
|
+
recipient = AddressData(
|
|
1255
|
+
required=True,
|
|
1256
|
+
help_text="""The address of the party.<br/>
|
|
1257
|
+
Origin address (ship from) for the **shipper**<br/>
|
|
1258
|
+
Destination address (ship to) for the **recipient**
|
|
1259
|
+
""",
|
|
1260
|
+
)
|
|
1261
|
+
shipper = AddressData(
|
|
1262
|
+
required=True,
|
|
1263
|
+
help_text="""The address of the party.<br/>
|
|
1264
|
+
Origin address (ship from) for the **shipper**<br/>
|
|
1265
|
+
Destination address (ship to) for the **recipient**
|
|
1266
|
+
""",
|
|
1267
|
+
)
|
|
1268
|
+
return_address = AddressData(
|
|
1269
|
+
required=False,
|
|
1270
|
+
allow_null=True,
|
|
1271
|
+
help_text="The return address for this shipment. Defaults to the shipper address.",
|
|
1272
|
+
)
|
|
1273
|
+
billing_address = AddressData(
|
|
1274
|
+
required=False,
|
|
1275
|
+
allow_null=True,
|
|
1276
|
+
help_text="The payor address.",
|
|
1277
|
+
)
|
|
1278
|
+
parcels = ParcelData(
|
|
1279
|
+
many=True,
|
|
1280
|
+
allow_empty=False,
|
|
1281
|
+
help_text="The shipment's parcels",
|
|
1282
|
+
)
|
|
1283
|
+
options = serializers.PlainDictField(
|
|
1284
|
+
required=False,
|
|
1285
|
+
default={},
|
|
1286
|
+
help_text="""<details>
|
|
1287
|
+
<summary>The options available for the shipment.</summary>
|
|
1288
|
+
|
|
1289
|
+
{
|
|
1290
|
+
"currency": "USD",
|
|
1291
|
+
"insurance": 100.00,
|
|
1292
|
+
"cash_on_delivery": 30.00,
|
|
1293
|
+
"dangerous_good": true,
|
|
1294
|
+
"declared_value": 150.00,
|
|
1295
|
+
"sms_notification": true,
|
|
1296
|
+
"email_notification": true,
|
|
1297
|
+
"email_notification_to": "shipper@mail.com",
|
|
1298
|
+
"hold_at_location": true,
|
|
1299
|
+
"paperless_trade": true,
|
|
1300
|
+
"preferred_service": "fedex_express_saver",
|
|
1301
|
+
"shipment_date": "2020-01-01", # TODO: deprecate
|
|
1302
|
+
"shipping_date": "2020-01-01T00:00",
|
|
1303
|
+
"shipment_note": "This is a shipment note",
|
|
1304
|
+
"signature_confirmation": true,
|
|
1305
|
+
"saturday_delivery": true,
|
|
1306
|
+
"is_return": true,
|
|
1307
|
+
"shipper_instructions": "This is a shipper instruction",
|
|
1308
|
+
"recipient_instructions": "This is a recipient instruction",
|
|
1309
|
+
"doc_files": [
|
|
1310
|
+
{
|
|
1311
|
+
"doc_type": "commercial_invoice",
|
|
1312
|
+
"doc_file": "base64 encoded file",
|
|
1313
|
+
"doc_name": "commercial_invoice.pdf",
|
|
1314
|
+
"doc_format": "pdf",
|
|
1315
|
+
}
|
|
1316
|
+
],
|
|
1317
|
+
"doc_references": [
|
|
1318
|
+
{
|
|
1319
|
+
"doc_id": "123456789",
|
|
1320
|
+
"doc_type": "commercial_invoice",
|
|
1321
|
+
}
|
|
1322
|
+
],
|
|
1323
|
+
}
|
|
1324
|
+
</details>
|
|
1325
|
+
""",
|
|
1326
|
+
)
|
|
1327
|
+
payment = Payment(
|
|
1328
|
+
required=False,
|
|
1329
|
+
default={},
|
|
1330
|
+
help_text="The payment details",
|
|
1331
|
+
)
|
|
1332
|
+
customs = CustomsData(
|
|
1333
|
+
required=False,
|
|
1334
|
+
allow_null=True,
|
|
1335
|
+
help_text="""The customs details.<br/>
|
|
1336
|
+
**Note that this is required for the shipment of an international Dutiable parcel.**
|
|
1337
|
+
""",
|
|
1338
|
+
)
|
|
1339
|
+
reference = serializers.CharField(
|
|
1340
|
+
required=False,
|
|
1341
|
+
allow_blank=True,
|
|
1342
|
+
allow_null=True,
|
|
1343
|
+
max_length=100,
|
|
1344
|
+
help_text="The shipment reference",
|
|
1345
|
+
)
|
|
1346
|
+
label_type = serializers.ChoiceField(
|
|
1347
|
+
required=False,
|
|
1348
|
+
choices=LABEL_TYPES,
|
|
1349
|
+
default=units.LabelType.PDF.name,
|
|
1350
|
+
help_text="The shipment label file type.",
|
|
1351
|
+
)
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
class ShippingRequest(ShippingData):
|
|
1355
|
+
selected_rate_id = serializers.CharField(
|
|
1356
|
+
required=True, help_text="The shipment selected rate."
|
|
1357
|
+
)
|
|
1358
|
+
rates = Rate(many=True, help_text="The list for shipment rates fetched previously")
|
|
1359
|
+
|
|
1360
|
+
|
|
1361
|
+
class ShipmentData(ShippingData):
|
|
1362
|
+
service = serializers.CharField(
|
|
1363
|
+
required=False,
|
|
1364
|
+
allow_blank=False,
|
|
1365
|
+
allow_null=False,
|
|
1366
|
+
help_text="**Specify a service to Buy a label in one call without rating.**",
|
|
1367
|
+
)
|
|
1368
|
+
services = serializers.StringListField(
|
|
1369
|
+
required=False,
|
|
1370
|
+
allow_null=True,
|
|
1371
|
+
default=[],
|
|
1372
|
+
help_text="""The requested carrier service for the shipment.<br/>
|
|
1373
|
+
Please consult the reference for specific carriers services.<br/>
|
|
1374
|
+
**Note that this is a list because on a Multi-carrier rate request
|
|
1375
|
+
you could specify a service per carrier.**
|
|
1376
|
+
""",
|
|
1377
|
+
)
|
|
1378
|
+
carrier_ids = serializers.StringListField(
|
|
1379
|
+
required=False,
|
|
1380
|
+
allow_null=True,
|
|
1381
|
+
default=[],
|
|
1382
|
+
help_text="""The list of configured carriers you wish to get rates from.<br/>
|
|
1383
|
+
**Note that the request will be sent to all carriers in nothing is specified**
|
|
1384
|
+
""",
|
|
1385
|
+
)
|
|
1386
|
+
metadata = serializers.PlainDictField(
|
|
1387
|
+
required=False,
|
|
1388
|
+
default={},
|
|
1389
|
+
help_text="User metadata for the shipment",
|
|
1390
|
+
)
|
|
1391
|
+
|
|
1392
|
+
|
|
1393
|
+
class ShipmentDetails(serializers.Serializer):
|
|
1394
|
+
status = serializers.ChoiceField(
|
|
1395
|
+
required=False,
|
|
1396
|
+
default=ShipmentStatus.draft.value,
|
|
1397
|
+
choices=SHIPMENT_STATUS,
|
|
1398
|
+
help_text="The current Shipment status",
|
|
1399
|
+
)
|
|
1400
|
+
carrier_name = serializers.CharField(
|
|
1401
|
+
required=False,
|
|
1402
|
+
allow_blank=True,
|
|
1403
|
+
allow_null=True,
|
|
1404
|
+
help_text="The shipment carrier",
|
|
1405
|
+
)
|
|
1406
|
+
carrier_id = serializers.CharField(
|
|
1407
|
+
required=False,
|
|
1408
|
+
allow_blank=True,
|
|
1409
|
+
allow_null=True,
|
|
1410
|
+
help_text="The shipment carrier configured identifier",
|
|
1411
|
+
)
|
|
1412
|
+
tracking_number = serializers.CharField(
|
|
1413
|
+
required=False,
|
|
1414
|
+
allow_blank=True,
|
|
1415
|
+
allow_null=True,
|
|
1416
|
+
help_text="The shipment tracking number",
|
|
1417
|
+
)
|
|
1418
|
+
shipment_identifier = serializers.CharField(
|
|
1419
|
+
required=False,
|
|
1420
|
+
allow_blank=True,
|
|
1421
|
+
allow_null=True,
|
|
1422
|
+
help_text="The shipment carrier system identifier",
|
|
1423
|
+
)
|
|
1424
|
+
selected_rate = Rate(
|
|
1425
|
+
required=False, allow_null=True, help_text="The shipment selected rate"
|
|
1426
|
+
)
|
|
1427
|
+
docs = Documents(
|
|
1428
|
+
required=False,
|
|
1429
|
+
allow_null=True,
|
|
1430
|
+
help_text="The shipment documents",
|
|
1431
|
+
)
|
|
1432
|
+
meta = serializers.PlainDictField(
|
|
1433
|
+
required=False, allow_null=True, help_text="provider specific metadata"
|
|
1434
|
+
)
|
|
1435
|
+
|
|
1436
|
+
service = serializers.CharField(
|
|
1437
|
+
required=False,
|
|
1438
|
+
allow_blank=True,
|
|
1439
|
+
allow_null=True,
|
|
1440
|
+
help_text="The selected service",
|
|
1441
|
+
)
|
|
1442
|
+
selected_rate_id = serializers.CharField(
|
|
1443
|
+
required=False,
|
|
1444
|
+
allow_blank=True,
|
|
1445
|
+
allow_null=True,
|
|
1446
|
+
help_text="The shipment selected rate.",
|
|
1447
|
+
)
|
|
1448
|
+
tracking_url = serializers.URLField(
|
|
1449
|
+
required=False,
|
|
1450
|
+
allow_blank=True,
|
|
1451
|
+
allow_null=True,
|
|
1452
|
+
help_text="The shipment tracking url",
|
|
1453
|
+
)
|
|
1454
|
+
test_mode = serializers.BooleanField(
|
|
1455
|
+
required=True,
|
|
1456
|
+
help_text="Specified whether it was created with a carrier in test mode",
|
|
1457
|
+
)
|
|
1458
|
+
|
|
1459
|
+
|
|
1460
|
+
class ShipmentContent(serializers.Serializer):
|
|
1461
|
+
object_type = serializers.CharField(
|
|
1462
|
+
default="shipment", help_text="Specifies the object type"
|
|
1463
|
+
)
|
|
1464
|
+
tracking_url = serializers.URLField(
|
|
1465
|
+
required=False,
|
|
1466
|
+
allow_blank=True,
|
|
1467
|
+
allow_null=True,
|
|
1468
|
+
help_text="The shipment tracking url",
|
|
1469
|
+
)
|
|
1470
|
+
shipper = Address(
|
|
1471
|
+
required=True,
|
|
1472
|
+
help_text="""The address of the party.<br/>
|
|
1473
|
+
Origin address (ship from) for the **shipper**<br/>
|
|
1474
|
+
Destination address (ship to) for the **recipient**
|
|
1475
|
+
""",
|
|
1476
|
+
)
|
|
1477
|
+
recipient = Address(
|
|
1478
|
+
required=True,
|
|
1479
|
+
help_text="""The address of the party.<br/>
|
|
1480
|
+
Origin address (ship from) for the **shipper**<br/>
|
|
1481
|
+
Destination address (ship to) for the **recipient**
|
|
1482
|
+
""",
|
|
1483
|
+
)
|
|
1484
|
+
return_address = AddressData(
|
|
1485
|
+
required=False,
|
|
1486
|
+
allow_null=True,
|
|
1487
|
+
help_text="The return address for this shipment. Defaults to the shipper address.",
|
|
1488
|
+
)
|
|
1489
|
+
billing_address = AddressData(
|
|
1490
|
+
required=False,
|
|
1491
|
+
allow_null=True,
|
|
1492
|
+
help_text="The payor address.",
|
|
1493
|
+
)
|
|
1494
|
+
parcels = Parcel(
|
|
1495
|
+
many=True,
|
|
1496
|
+
allow_empty=False,
|
|
1497
|
+
help_text="The shipment's parcels",
|
|
1498
|
+
)
|
|
1499
|
+
services = serializers.StringListField(
|
|
1500
|
+
required=False,
|
|
1501
|
+
allow_null=True,
|
|
1502
|
+
default=[],
|
|
1503
|
+
help_text="""The carriers services requested for the shipment.<br/>
|
|
1504
|
+
Please consult the reference for specific carriers services.<br/>
|
|
1505
|
+
**Note that this is a list because on a Multi-carrier rate request you could specify a service per carrier.**
|
|
1506
|
+
""",
|
|
1507
|
+
)
|
|
1508
|
+
options = serializers.PlainDictField(
|
|
1509
|
+
required=False,
|
|
1510
|
+
default={},
|
|
1511
|
+
help_text="""<details>
|
|
1512
|
+
<summary>The options available for the shipment.</summary>
|
|
1513
|
+
|
|
1514
|
+
{
|
|
1515
|
+
"currency": "USD",
|
|
1516
|
+
"insurance": 100.00,
|
|
1517
|
+
"cash_on_delivery": 30.00,
|
|
1518
|
+
"dangerous_good": true,
|
|
1519
|
+
"declared_value": 150.00,
|
|
1520
|
+
"sms_notification": true,
|
|
1521
|
+
"email_notification": true,
|
|
1522
|
+
"email_notification_to": "shipper@mail.com",
|
|
1523
|
+
"hold_at_location": true,
|
|
1524
|
+
"paperless_trade": true,
|
|
1525
|
+
"preferred_service": "fedex_express_saver",
|
|
1526
|
+
"shipment_date": "2020-01-01", # TODO: deprecate
|
|
1527
|
+
"shipping_date": "2020-01-01T00:00",
|
|
1528
|
+
"shipment_note": "This is a shipment note",
|
|
1529
|
+
"signature_confirmation": true,
|
|
1530
|
+
"saturday_delivery": true,
|
|
1531
|
+
"is_return": true,
|
|
1532
|
+
"shipper_instructions": "This is a shipper instruction",
|
|
1533
|
+
"recipient_instructions": "This is a recipient instruction",
|
|
1534
|
+
"doc_files": [
|
|
1535
|
+
{
|
|
1536
|
+
"doc_type": "commercial_invoice",
|
|
1537
|
+
"doc_file": "base64 encoded file",
|
|
1538
|
+
"doc_name": "commercial_invoice.pdf",
|
|
1539
|
+
"doc_format": "pdf",
|
|
1540
|
+
}
|
|
1541
|
+
],
|
|
1542
|
+
"doc_references": [
|
|
1543
|
+
{
|
|
1544
|
+
"doc_id": "123456789",
|
|
1545
|
+
"doc_type": "commercial_invoice",
|
|
1546
|
+
}
|
|
1547
|
+
],
|
|
1548
|
+
}
|
|
1549
|
+
</details>
|
|
1550
|
+
""",
|
|
1551
|
+
)
|
|
1552
|
+
payment = Payment(
|
|
1553
|
+
required=False,
|
|
1554
|
+
default={},
|
|
1555
|
+
help_text="The payment details",
|
|
1556
|
+
)
|
|
1557
|
+
customs = Customs(
|
|
1558
|
+
required=False,
|
|
1559
|
+
allow_null=True,
|
|
1560
|
+
help_text="""The customs details.<br/>
|
|
1561
|
+
**Note that this is required for the shipment of an international Dutiable parcel.**
|
|
1562
|
+
""",
|
|
1563
|
+
)
|
|
1564
|
+
rates = Rate(
|
|
1565
|
+
many=True,
|
|
1566
|
+
required=False,
|
|
1567
|
+
default=[],
|
|
1568
|
+
help_text="The list for shipment rates fetched previously",
|
|
1569
|
+
)
|
|
1570
|
+
reference = serializers.CharField(
|
|
1571
|
+
required=False,
|
|
1572
|
+
allow_blank=True,
|
|
1573
|
+
allow_null=True,
|
|
1574
|
+
help_text="The shipment reference",
|
|
1575
|
+
)
|
|
1576
|
+
label_type = serializers.ChoiceField(
|
|
1577
|
+
required=False,
|
|
1578
|
+
choices=LABEL_TYPES,
|
|
1579
|
+
allow_blank=True,
|
|
1580
|
+
allow_null=True,
|
|
1581
|
+
help_text="The shipment label file type.",
|
|
1582
|
+
)
|
|
1583
|
+
carrier_ids = serializers.StringListField(
|
|
1584
|
+
required=False,
|
|
1585
|
+
allow_null=True,
|
|
1586
|
+
default=[],
|
|
1587
|
+
help_text="""The list of configured carriers you wish to get rates from.<br/>
|
|
1588
|
+
**Note that the request will be sent to all carriers in nothing is specified**
|
|
1589
|
+
""",
|
|
1590
|
+
)
|
|
1591
|
+
tracker_id = serializers.CharField(
|
|
1592
|
+
required=False,
|
|
1593
|
+
allow_blank=True,
|
|
1594
|
+
allow_null=True,
|
|
1595
|
+
help_text="The attached tracker id",
|
|
1596
|
+
)
|
|
1597
|
+
created_at = serializers.CharField(
|
|
1598
|
+
required=True,
|
|
1599
|
+
help_text="""The shipment creation datetime.<br/>
|
|
1600
|
+
Date Format: `YYYY-MM-DD HH:MM:SS.mmmmmmz`
|
|
1601
|
+
""",
|
|
1602
|
+
)
|
|
1603
|
+
metadata = serializers.PlainDictField(
|
|
1604
|
+
required=False, default={}, help_text="User metadata for the shipment"
|
|
1605
|
+
)
|
|
1606
|
+
messages = Message(
|
|
1607
|
+
required=False,
|
|
1608
|
+
many=True,
|
|
1609
|
+
default=[],
|
|
1610
|
+
help_text="The list of note or warning messages",
|
|
1611
|
+
)
|
|
1612
|
+
|
|
1613
|
+
|
|
1614
|
+
class Shipment(serializers.EntitySerializer, ShipmentContent, ShipmentDetails):
|
|
1615
|
+
docs = None
|
|
1616
|
+
label_url = serializers.URLField(
|
|
1617
|
+
required=False,
|
|
1618
|
+
allow_blank=True,
|
|
1619
|
+
allow_null=True,
|
|
1620
|
+
help_text="The shipment label URL",
|
|
1621
|
+
)
|
|
1622
|
+
invoice_url = serializers.URLField(
|
|
1623
|
+
required=False,
|
|
1624
|
+
allow_blank=True,
|
|
1625
|
+
allow_null=True,
|
|
1626
|
+
help_text="The shipment invoice URL",
|
|
1627
|
+
)
|
|
1628
|
+
|
|
1629
|
+
|
|
1630
|
+
class ShipmentCancelRequest(serializers.Serializer):
|
|
1631
|
+
shipment_identifier = serializers.CharField(
|
|
1632
|
+
required=True,
|
|
1633
|
+
help_text="The shipment identifier returned during creation.",
|
|
1634
|
+
)
|
|
1635
|
+
service = serializers.CharField(
|
|
1636
|
+
required=False,
|
|
1637
|
+
allow_blank=True,
|
|
1638
|
+
allow_null=True,
|
|
1639
|
+
help_text="The selected shipment service",
|
|
1640
|
+
)
|
|
1641
|
+
carrier_id = serializers.CharField(
|
|
1642
|
+
required=False,
|
|
1643
|
+
help_text="The shipment carrier_id for specific connection selection.",
|
|
1644
|
+
)
|
|
1645
|
+
options = serializers.PlainDictField(
|
|
1646
|
+
required=False,
|
|
1647
|
+
default={},
|
|
1648
|
+
help_text="Advanced carrier specific cancellation options.",
|
|
1649
|
+
)
|
|
1650
|
+
|
|
1651
|
+
|
|
1652
|
+
@serializers.allow_model_id(
|
|
1653
|
+
[
|
|
1654
|
+
("address", "karrio.server.manager.models.Address"),
|
|
1655
|
+
]
|
|
1656
|
+
)
|
|
1657
|
+
class ManifestRequestData(serializers.Serializer):
|
|
1658
|
+
carrier_name = serializers.CharField(
|
|
1659
|
+
required=True, help_text="The manifest's carrier"
|
|
1660
|
+
)
|
|
1661
|
+
address = AddressData(
|
|
1662
|
+
required=True,
|
|
1663
|
+
help_text="The address of the warehouse or location where the shipments originate.",
|
|
1664
|
+
)
|
|
1665
|
+
options = serializers.PlainDictField(
|
|
1666
|
+
required=False,
|
|
1667
|
+
default={},
|
|
1668
|
+
help_text="""<details>
|
|
1669
|
+
<summary>The options available for the manifest.</summary>
|
|
1670
|
+
|
|
1671
|
+
{
|
|
1672
|
+
"shipments": [
|
|
1673
|
+
{
|
|
1674
|
+
"tracking_number": "123456789",
|
|
1675
|
+
...
|
|
1676
|
+
"meta": {...}
|
|
1677
|
+
}
|
|
1678
|
+
]
|
|
1679
|
+
}
|
|
1680
|
+
</details>
|
|
1681
|
+
""",
|
|
1682
|
+
)
|
|
1683
|
+
reference = serializers.CharField(
|
|
1684
|
+
required=False,
|
|
1685
|
+
allow_blank=True,
|
|
1686
|
+
allow_null=True,
|
|
1687
|
+
help_text="The manifest reference",
|
|
1688
|
+
)
|
|
1689
|
+
|
|
1690
|
+
|
|
1691
|
+
class ManifestRequest(ManifestRequestData):
|
|
1692
|
+
shipment_identifiers = serializers.StringListField(
|
|
1693
|
+
required=True,
|
|
1694
|
+
help_text="""The list of shipment identifiers you want to add to your manifest.<br/>
|
|
1695
|
+
shipment_identifier is often a tracking_number or shipment_id returned when you purchase a label.
|
|
1696
|
+
""",
|
|
1697
|
+
)
|
|
1698
|
+
|
|
1699
|
+
|
|
1700
|
+
class ManifestData(ManifestRequestData):
|
|
1701
|
+
shipment_ids = serializers.StringListField(
|
|
1702
|
+
required=True,
|
|
1703
|
+
help_text="""The list of existing shipment object ids with label purchased.""",
|
|
1704
|
+
)
|
|
1705
|
+
|
|
1706
|
+
|
|
1707
|
+
class ManifestDocument(serializers.Serializer):
|
|
1708
|
+
manifest = serializers.CharField(
|
|
1709
|
+
required=False,
|
|
1710
|
+
allow_blank=True,
|
|
1711
|
+
allow_null=True,
|
|
1712
|
+
help_text="A manifest file in base64 string",
|
|
1713
|
+
)
|
|
1714
|
+
|
|
1715
|
+
|
|
1716
|
+
class ManifestDetails(serializers.Serializer):
|
|
1717
|
+
id = serializers.CharField(required=False, help_text="A unique manifest identifier")
|
|
1718
|
+
object_type = serializers.CharField(
|
|
1719
|
+
default="manifest", help_text="Specifies the object type"
|
|
1720
|
+
)
|
|
1721
|
+
carrier_name = serializers.CharField(
|
|
1722
|
+
required=True, help_text="The manifest carrier"
|
|
1723
|
+
)
|
|
1724
|
+
carrier_id = serializers.CharField(
|
|
1725
|
+
required=True, help_text="The manifest carrier configured name"
|
|
1726
|
+
)
|
|
1727
|
+
doc = ManifestDocument(
|
|
1728
|
+
required=False,
|
|
1729
|
+
allow_null=True,
|
|
1730
|
+
help_text="The manifest documents",
|
|
1731
|
+
)
|
|
1732
|
+
meta = serializers.PlainDictField(
|
|
1733
|
+
required=False, allow_null=True, help_text="provider specific metadata"
|
|
1734
|
+
)
|
|
1735
|
+
test_mode = serializers.BooleanField(
|
|
1736
|
+
required=True,
|
|
1737
|
+
help_text="Specified whether it was created with a carrier in test mode",
|
|
1738
|
+
)
|
|
1739
|
+
|
|
1740
|
+
|
|
1741
|
+
class Manifest(ManifestDetails, ManifestRequest):
|
|
1742
|
+
doc = None
|
|
1743
|
+
metadata = serializers.PlainDictField(
|
|
1744
|
+
required=False, default={}, help_text="User metadata for the pickup"
|
|
1745
|
+
)
|
|
1746
|
+
manifest_url = serializers.URLField(
|
|
1747
|
+
required=False,
|
|
1748
|
+
allow_blank=True,
|
|
1749
|
+
allow_null=True,
|
|
1750
|
+
help_text="The Manifest file URL",
|
|
1751
|
+
)
|
|
1752
|
+
messages = Message(
|
|
1753
|
+
required=False,
|
|
1754
|
+
many=True,
|
|
1755
|
+
default=[],
|
|
1756
|
+
help_text="The list of note or warning messages",
|
|
1757
|
+
)
|
|
1758
|
+
|
|
1759
|
+
|
|
1760
|
+
class ManifestResponse(serializers.Serializer):
|
|
1761
|
+
messages = Message(
|
|
1762
|
+
required=False, many=True, help_text="The list of note or warning messages"
|
|
1763
|
+
)
|
|
1764
|
+
manifest = ManifestDetails(required=False, help_text="The manifest details")
|
|
1765
|
+
|
|
1766
|
+
|
|
1767
|
+
class Operation(serializers.Serializer):
|
|
1768
|
+
operation = serializers.CharField(required=True, help_text="Operation performed")
|
|
1769
|
+
success = serializers.BooleanField(
|
|
1770
|
+
required=True, help_text="Specify whether the operation was successful"
|
|
1771
|
+
)
|
|
1772
|
+
|
|
1773
|
+
|
|
1774
|
+
class OperationConfirmation(Operation):
|
|
1775
|
+
carrier_name = serializers.CharField(
|
|
1776
|
+
required=True, help_text="The operation carrier"
|
|
1777
|
+
)
|
|
1778
|
+
carrier_id = serializers.CharField(
|
|
1779
|
+
required=False,
|
|
1780
|
+
allow_blank=True,
|
|
1781
|
+
allow_null=True,
|
|
1782
|
+
help_text="The targeted carrier's name (unique identifier)",
|
|
1783
|
+
)
|
|
1784
|
+
|
|
1785
|
+
|
|
1786
|
+
class OperationResponse(serializers.Serializer):
|
|
1787
|
+
messages = Message(
|
|
1788
|
+
required=False, many=True, help_text="The list of note or warning messages"
|
|
1789
|
+
)
|
|
1790
|
+
confirmation = OperationConfirmation(
|
|
1791
|
+
required=False, help_text="The operation details"
|
|
1792
|
+
)
|
|
1793
|
+
|
|
1794
|
+
|
|
1795
|
+
class PickupResponse(serializers.Serializer):
|
|
1796
|
+
messages = Message(
|
|
1797
|
+
required=False, many=True, help_text="The list of note or warning messages"
|
|
1798
|
+
)
|
|
1799
|
+
pickup = Pickup(required=False, help_text="The scheduled pickup's summary")
|
|
1800
|
+
|
|
1801
|
+
|
|
1802
|
+
class RateResponse(serializers.Serializer):
|
|
1803
|
+
messages = Message(
|
|
1804
|
+
required=False, many=True, help_text="The list of note or warning messages"
|
|
1805
|
+
)
|
|
1806
|
+
rates = Rate(many=True, help_text="The list of returned rates")
|
|
1807
|
+
|
|
1808
|
+
|
|
1809
|
+
class TrackingResponse(serializers.Serializer):
|
|
1810
|
+
messages = Message(
|
|
1811
|
+
required=False, many=True, help_text="The list of note or warning messages"
|
|
1812
|
+
)
|
|
1813
|
+
tracking = TrackerDetails(
|
|
1814
|
+
required=False, help_text="The tracking details retrieved"
|
|
1815
|
+
)
|
|
1816
|
+
|
|
1817
|
+
|
|
1818
|
+
class DocumentFileData(serializers.Serializer):
|
|
1819
|
+
doc_file = serializers.CharField(
|
|
1820
|
+
required=True,
|
|
1821
|
+
validators=[validators.valid_base64("doc_file")],
|
|
1822
|
+
help_text="A base64 file to upload",
|
|
1823
|
+
)
|
|
1824
|
+
doc_name = serializers.CharField(
|
|
1825
|
+
required=True,
|
|
1826
|
+
help_text="The file name",
|
|
1827
|
+
)
|
|
1828
|
+
doc_format = serializers.CharField(
|
|
1829
|
+
required=False,
|
|
1830
|
+
allow_blank=False,
|
|
1831
|
+
allow_null=True,
|
|
1832
|
+
help_text="The file format",
|
|
1833
|
+
)
|
|
1834
|
+
doc_type = serializers.CharField(
|
|
1835
|
+
required=False,
|
|
1836
|
+
allow_blank=False,
|
|
1837
|
+
allow_null=True,
|
|
1838
|
+
max_length=50,
|
|
1839
|
+
default="other",
|
|
1840
|
+
help_text=f"""
|
|
1841
|
+
Shipment document type
|
|
1842
|
+
|
|
1843
|
+
values: <br/>
|
|
1844
|
+
{' '.join([f'`{pkg}`' for pkg, _ in UPLOAD_DOCUMENT_TYPE])}
|
|
1845
|
+
|
|
1846
|
+
For carrier specific packaging types, please consult the reference.
|
|
1847
|
+
""",
|
|
1848
|
+
)
|
|
1849
|
+
|
|
1850
|
+
|
|
1851
|
+
class DocumentUploadData(serializers.Serializer):
|
|
1852
|
+
shipment_id = serializers.CharField(
|
|
1853
|
+
required=True, help_text="The documents related shipment."
|
|
1854
|
+
)
|
|
1855
|
+
document_files = DocumentFileData(
|
|
1856
|
+
many=True,
|
|
1857
|
+
allow_empty=False,
|
|
1858
|
+
help_text="Shipping document files",
|
|
1859
|
+
)
|
|
1860
|
+
reference = serializers.CharField(
|
|
1861
|
+
required=False,
|
|
1862
|
+
allow_blank=False,
|
|
1863
|
+
allow_null=True,
|
|
1864
|
+
max_length=50,
|
|
1865
|
+
help_text="Shipping document file reference",
|
|
1866
|
+
)
|
|
1867
|
+
|
|
1868
|
+
|
|
1869
|
+
class DocumentDetails(serializers.Serializer):
|
|
1870
|
+
doc_id = serializers.CharField(
|
|
1871
|
+
required=False,
|
|
1872
|
+
help_text="The uploaded document id.",
|
|
1873
|
+
)
|
|
1874
|
+
file_name = serializers.CharField(
|
|
1875
|
+
required=False,
|
|
1876
|
+
help_text="The uploaded document file name.",
|
|
1877
|
+
)
|
|
1878
|
+
|
|
1879
|
+
|
|
1880
|
+
class DocumentUploadRecord(serializers.EntitySerializer):
|
|
1881
|
+
carrier_name = serializers.CharField(
|
|
1882
|
+
required=False,
|
|
1883
|
+
allow_blank=True,
|
|
1884
|
+
allow_null=True,
|
|
1885
|
+
help_text="The shipment carrier",
|
|
1886
|
+
)
|
|
1887
|
+
carrier_id = serializers.CharField(
|
|
1888
|
+
required=False,
|
|
1889
|
+
allow_blank=True,
|
|
1890
|
+
allow_null=True,
|
|
1891
|
+
help_text="The shipment carrier configured identifier",
|
|
1892
|
+
)
|
|
1893
|
+
documents = DocumentDetails(
|
|
1894
|
+
many=True,
|
|
1895
|
+
default=[],
|
|
1896
|
+
required=False,
|
|
1897
|
+
help_text="the carrier shipping document ids",
|
|
1898
|
+
)
|
|
1899
|
+
meta = serializers.PlainDictField(
|
|
1900
|
+
required=False,
|
|
1901
|
+
allow_null=True,
|
|
1902
|
+
help_text="provider specific metadata",
|
|
1903
|
+
)
|
|
1904
|
+
reference = serializers.CharField(
|
|
1905
|
+
required=False,
|
|
1906
|
+
allow_blank=False,
|
|
1907
|
+
allow_null=True,
|
|
1908
|
+
max_length=50,
|
|
1909
|
+
help_text="Shipping document file reference",
|
|
1910
|
+
)
|
|
1911
|
+
messages = Message(
|
|
1912
|
+
required=False,
|
|
1913
|
+
many=True,
|
|
1914
|
+
default=[],
|
|
1915
|
+
help_text="The list of note or warning messages",
|
|
1916
|
+
)
|
|
1917
|
+
|
|
1918
|
+
|
|
1919
|
+
class OAuthAuthorizeData(serializers.Serializer):
|
|
1920
|
+
"""OAuth authorization request data serializer."""
|
|
1921
|
+
|
|
1922
|
+
state = serializers.CharField(
|
|
1923
|
+
required=True,
|
|
1924
|
+
help_text="A unique state value for CSRF protection.",
|
|
1925
|
+
)
|
|
1926
|
+
redirect_uri = serializers.CharField(
|
|
1927
|
+
required=False,
|
|
1928
|
+
allow_null=True,
|
|
1929
|
+
help_text="The URI to redirect to after authorization.",
|
|
1930
|
+
)
|
|
1931
|
+
options = serializers.PlainDictField(
|
|
1932
|
+
required=False,
|
|
1933
|
+
default={},
|
|
1934
|
+
help_text="Additional carrier-specific options.",
|
|
1935
|
+
)
|
|
1936
|
+
|
|
1937
|
+
|
|
1938
|
+
class OAuthCallbackData(serializers.Serializer):
|
|
1939
|
+
"""OAuth callback request data serializer."""
|
|
1940
|
+
|
|
1941
|
+
url = serializers.CharField(
|
|
1942
|
+
required=True,
|
|
1943
|
+
help_text="The full callback URL.",
|
|
1944
|
+
)
|
|
1945
|
+
query = serializers.PlainDictField(
|
|
1946
|
+
required=False,
|
|
1947
|
+
default={},
|
|
1948
|
+
help_text="The query parameters from the callback URL.",
|
|
1949
|
+
)
|
|
1950
|
+
body = serializers.PlainDictField(
|
|
1951
|
+
required=False,
|
|
1952
|
+
default={},
|
|
1953
|
+
help_text="The request body if any.",
|
|
1954
|
+
)
|
|
1955
|
+
headers = serializers.PlainDictField(
|
|
1956
|
+
required=False,
|
|
1957
|
+
default={},
|
|
1958
|
+
help_text="The request headers.",
|
|
1959
|
+
)
|
|
1960
|
+
|
|
1961
|
+
|
|
1962
|
+
class ErrorMessages(serializers.Serializer):
|
|
1963
|
+
messages = Message(
|
|
1964
|
+
many=True,
|
|
1965
|
+
required=False,
|
|
1966
|
+
help_text="The list of error messages",
|
|
1967
|
+
)
|
|
1968
|
+
|
|
1969
|
+
|
|
1970
|
+
class ErrorResponse(serializers.Serializer):
|
|
1971
|
+
errors = APIError(many=True, required=False, help_text="The list of API errors")
|