Date: March 5, 2025
We successfully implemented and tested the BoxKnight carrier integration for the Karrio shipping platform. This was a comprehensive project that required careful planning and execution.
Initial Setup and Structure
We began by creating the necessary directory structure for the BoxKnight plugin, establishing the foundation for a well-organized integration.
Creating Core Files
We implemented several key files for the integration:
- Mapper Files: Created __init__.py with metadata, mapper.py for transforming requests/responses, proxy.py for API communication, and settings.py for configuration
- Provider Files: Implemented error.py for error handling, rate.py for rate functionality, tracking.py for tracking capabilities, utils.py for API utilities, and units.py for BoxKnight services and options
- Schema Files: Defined JSON schema definitions for various API payloads and set up the structure for Python type generation
Implementing the Generate Script
We created a generate script to automate the generation of Python types from JSON schema definitions, streamlining the development process.
Fixing Metadata Initialization
We encountered and resolved an issue with the Metadata initialization in the BoxKnight mapper by removing the redundant status parameter that was already defined with a default value in the Metadata class.
Creating Test Infrastructure
Since the BoxKnight provider wasn't yet registered with Karrio, we needed to create a mock gateway for testing:
- Updated fixture.py to support the new provider
- Created test_rate.py to verify rate functionality
Fixing the Tracking Implementation
We identified and fixed an issue with the tracking implementation where lib.flocaltime was being used but didn't exist. We replaced it with lib.fdate to ensure proper functionality.
Creating Tracking Tests
We implemented comprehensive tests for the tracking functionality to ensure reliability.
Running and Verifying Tests
We ran the tests to verify that the integration was working correctly. All tests passed successfully, confirming that:
- The rate functionality correctly parses rate responses
- The tracking functionality correctly parses tracking responses
Final Structure
The final structure of the BoxKnight integration includes:
- 29 Python files organized in a modular structure
- 5 JSON schema files for type generation
- 2 test files covering rate and tracking functionality
- A generate script for automating type generation
This successful implementation of the BoxKnight carrier integration for Karrio includes core functionality for rates and tracking, JSON schema definitions and Python type generation, and comprehensive tests that verify the integration works correctly. The integration is now ready for further development and eventual registration with the Karrio gateway.