pkg_dpd_api_client version: 0.1.9

Published 2026-02-02

reinbeumer

sdk | dart
repository | svn
platform | generic
status | n/a
  • Readme
  • Changelog
  • Versions

pkg_dpd_api_client

A Dart client for DPD (Dynamic Parcel Distribution) SOAP services. It focuses on:

  • Building and parsing requests/responses for Shipment, Parcel Lifecycle, and Parcel Shop Finder services.
  • Normalizing errors into consistent ModelDpdError instances with DpdErrorCode mapping.
  • Hermetic unit tests for parsing/mapping logic without requiring network or environment files.

graph

This package is part of a monorepo and depends on pkg_core via a relative path. Consumers should import the single library entry:

import 'package:pkg_dpd_api_client/pkg_dpd_api_client.dart';

Features

  • Rich models for request/response payloads across DPD domains.
  • Centralized error handling via DpdErrorHandler and ModelDpdError.
  • Resilient SOAP fault parsing using package:xml with namespace-agnostic handling.
  • Logging helpers with optional file logging (disabled by default) and secret redaction.
  • Well-defined public API - see Public API Guidelines for stable vs internal APIs.

Quick start (contributors)

  1. Ensure Dart 3.8.x and that ../pkg_core exists and is resolvable.
  2. From repo root: dart pub get
  3. Run unit tests: dart test -r expanded (tests are hermetic; no network or .env required)
  4. Make changes; keep tests focused on parsing/mapping/model behavior.

Usage (library consumers)

  • Import the single entrypoint and use services/models as needed.
  • Error handling: catch and inspect ModelDpdError; use isRetryable/isAuthenticationError helpers.
  • Important: Only use the documented public APIs. See Public API Guidelines for details on what's stable.

Public API Overview

Main Services:

  • DpdClientFactory - Create service instances with managed HTTP client
  • DpdShipmentService - Shipment operations
  • DpdParcelLifecycleService - Tracking and label retrieval
  • DpdParcelShopFinderService - Find parcel shops
  • DpdLoginService - Authentication

Utilities:

  • AddressRequestBuilder - Build addresses with phone validation
  • DpdErrorHandler - Error normalization
  • LoggingUtil - Logging setup
  • Result<T, E> - Safe error handling

Models & Enums:

  • All request/response models
  • All enums (order types, country codes, etc.)

See Public API Guidelines for complete details and usage examples.

Example (error mapping only, no network):

import 'package:pkg_dpd_api_client/pkg_dpd_api_client.dart';

void main() { final err = ModelDpdError(message: 'Service unavailable'); if (err.isRetryable) { // backoff and retry } }

Environment variables (for the example app)

The CLI/example at example/pkg_dpd_api_client_example.dart requires a local assets/.env. Do not use these in unit tests.

Common flags:

  • DPD_TEST_ENVIRONMENT: true/false to select test vs live endpoints.

Test environment variables (used when DPD_TEST_ENVIRONMENT=true):

  • DPD_DELISID_TEST: Test DelisID (username)
  • DPD_PASSWORD_TEST: Test password
  • DPD_LOGIN_SERVICE_ENDPOINT_TEST: Login service WSDL/SOAP endpoint
  • DPD_PARCEL_SHOP_FINDER_SERVICE_ENDPOINT_TEST: Parcel Shop Finder SOAP endpoint
  • DPD_PARCEL_LIFECYCLE_SERVICE_ENDPOINT_TEST: Parcel Lifecycle SOAP endpoint
  • DPD_SHIPMENT_SERVICE_ENDPOINT_TEST: Shipment SOAP endpoint
  • DPD_HHP_DEPOT_NUMBER: Depot number (required for shipments)
  • DPD_MESSAGE_LANGUAGE: Two-letter language code (e.g., EN, NL)
  • DPD_HHP_EORI_NUMBER: EORI number for HHP
  • DPD_HHP_VAT_NUMBER: VAT number for HHP
  • DPD_HHP_IBAN_NUMBER: IBAN for HHP
  • DPD_HHP_KVK_NUMBER: Chamber of Commerce/registration (KvK) number for HHP
  • DPD_HHP_GLN_NUMBER: GLN number for HHP
  • DPD_APS_EORI_NUMBER: Optional APS EORI number
  • DPD_APS_VAT_NUMBER: Optional APS VAT number

Live environment variables (used when DPD_TEST_ENVIRONMENT=false):

  • DPD_DELISID: Live DelisID
  • DPD_PASSWORD: Live password
  • DPD_LOGIN_SERVICE_ENDPOINT: Login service endpoint
  • DPD_PARCEL_SHOP_FINDER_SERVICE_ENDPOINT: Parcel Shop Finder endpoint
  • DPD_PARCEL_LIFECYCLE_SERVICE_ENDPOINT: Parcel Lifecycle endpoint
  • DPD_SHIPMENT_SERVICE_ENDPOINT: Shipment endpoint

Notes:

  • Keep assets/.env out of version control (do not commit secrets).
  • The example prints logs to console by default. File logging can be enabled explicitly via LoggingUtil (enableFileLogging=true).

Example (manual) prerequisites

The example at example/pkg_dpd_api_client_example.dart is intended for manual/local runs only and is not used by unit tests.

Prerequisites:

  • Create assets/.env with valid DPD credentials and endpoints (see variables above). Do not commit secrets.
  • Ensure network access to the configured endpoints.
  • Optionally enable file logging if you want logs written under logs/.

Expected behavior:

  • With assets/.env present, the example logs environment load status and subsequent service interactions to console (and optionally to logs/ when enabled).
  • On missing assets/.env, the example exits with a non-zero code after logging a fatal message.

Developer docs

  • Error mapping policy: see docs/error_mapping.md

Example flags

  • --dry-run: Build and print the StoreOrders XML payload without loading assets/.env or performing any network calls.
  • --save-labels: When not in --dry-run mode, opt-in to saving generated label PDFs to assets/labels.

Usage examples:

  • dart run example/pkg_dpd_api_client_example.dart --dry-run
  • dart run example/pkg_dpd_api_client_example.dart --save-labels

Tooling pin (optional)

If you use asdf, this repository includes a .tool-versions file pinning Dart 3.8.1. You can also use fvm to pin Dart 3.8.x if preferred.

Error surface: throw vs Result

  • Services throw ModelDpdError on failures. Inspect errorCode, httpStatusCode, message, and helpers like isRetryable/isAuthenticationError.
  • For non-throwing ergonomics, use DpdShipmentService Result-returning methods (Ok/Err):
final svc = DpdShipmentService(config, httpClient);
final res = await svc.storeOrdersResult(request: req);
res.switch(
  (ok) => print('stored: ${ok.storeOrders}'),
  (err) => print('error: ${err.errorCode} ${err.message}'),
);
  • Low-level services (StoreOrderService, ExportOrderService, etc.) throw ModelDpdError; orchestrator exposes Result variants.
  • Network calls and retries are centralized. postWithRetry maps exceptions and 5xx responses to ModelDpdError; services add context so errors are traceable.

Changelog

0.1.9 - 2026-02-02

Changed

  • Version bump from 0.1.8 to 0.1.9 (lints -> 6.1.0 (was 6.0.0)).

0.1.8 - 2026-01-16

Changed

  • Version bump from 0.1.7 to 0.1.8 (meta -> 1.17.0 (was 1.18.0)).

0.1.7 - 2026-01-16

Changed

  • Version bump from 0.1.6 to 0.1.7 (meta -> 1.18.0 (was 1.17.0)).

0.1.6 - 2026-01-08

Changed

  • Version bump from 0.1.5 to 0.1.6 (test -> 1.29.0 (was 1.28.0)).

0.1.5 - 2025-11-21

Changed

  • Version bump from 0.1.4 to 0.1.5 (test -> 1.28.0 (was 1.27.0)).

0.1.4 - 2025-11-13

Changed

  • Version bump from 0.1.3 to 0.1.4 (meta -> 1.17.0 (was 1.16.0)).

0.1.3 - 2025-11-11

Changed

  • Version bump from 0.1.2 to 0.1.3 (test -> 1.27.0 (was 1.26.3)).

0.1.2 - 2025-11-10

Changed

  • Version bump from 0.1.1 to 0.1.2 (http -> 1.6.0 (was 1.5.0)).

0.1.1 - 2025-11-10

Changed

  • Version bump from 0.1.0 to 0.1.1 (meta -> 1.60.0 (was 1.17.0)).

0.1.0 - 2025-11-07

Changed - BREAKING (Internal Structure Only)

  • Major Refactoring: Converted from part/part of to proper library structure
  • All 121 files now standalone libraries with explicit imports
  • No API changes: All public APIs remain exactly the same
  • Focused barrel files: Created hierarchical export structure
    • lib/src/enums/enums.dart - All enums
    • lib/src/models/models.dart - All models (with sub-barrels for domains)
    • lib/src/services/services.dart - Main services only
    • lib/src/utils/utils.dart - Public utilities only

Added

  • Proper encapsulation: Internal implementations are no longer automatically visible
  • Sub-barrel files for better organization:
    • Models: core.dart, shipment/shipment.dart, parcel_lifecycle/parcel_lifecycle.dart, parcel_shop_finder/parcel_shop_finder.dart
    • Each domain has *_requests.dart and *_responses.dart sub-barrels
  • Cleaner main library: Now exports only 4 focused barrel files instead of 120+ individual files
  • Better maintainability: Each file is self-contained with explicit dependencies

Documentation

  • Main library now has comprehensive API documentation with usage examples
  • Clear distinction between public and internal APIs
  • Each barrel file documents its purpose

Notes

  • This is version 0.1.0 to reflect the significant architectural change
  • No breaking changes for consumers - all imports still work the same way
  • Import package:pkg_dpd_api_client/pkg_dpd_api_client.dart as before
  • Internal structure is now more modular and easier to maintain
  • Future changes to internal implementation won't affect public API

0.0.6 - 2025-09-16

Changed

  • Version bump from 0.0.3 to 0.0.4 (xml -> 6.6.1 (was 6.5.0)).

0.0.5 - 2025-08-08

Changed

  • Version bump from 0.0.4 to 0.0.5 (http -> 1.5.0 (was 1.4.0)).

0.0.4 - 2025-07-23

Changed

  • Version bump from 0.0.3 to 0.0.4 (test -> 1.26.3 (was 1.26.2)).

0.0.3 - 2025-06-26

Changed

  • Version bump from 0.0.2 to 0.0.3 (lints -> 6.0.0 (was 5.0.0)).

0.0.2 - 2025-06-26

Changed

  • Version bump from 0.0.1 to 0.0.2 (test -> 1.26.2 (was 1.24.0)).

0.0.1 - 2025-06-26

  • Initial version.

0.1.9

2026-02-02 download

0.1.8

2026-01-16 download

0.1.5

2025-11-21 download

0.1.4

2025-11-13 download

0.1.3

2025-11-11 download

0.1.2

2025-11-10 download

0.1.0

2025-11-07 download

0.0.5

2025-08-08 download

0.0.4

2025-07-23 download

0.0.3

2025-06-26 download