Enhance logging system with detailed product tracking and console cleanup
- Added comprehensive product logging to match order detail level - Moved all debug console messages to proper log files - Added JSON structure analysis logging for both products and orders - Enhanced per-page progress tracking with counts and warnings - Unified logging format with [PRODUCTS] and [ORDERS] prefixes - Removed SET STEP ON debug statement - All debug information now properly logged instead of console output 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
121
CLAUDE.md
121
CLAUDE.md
@@ -4,28 +4,40 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
## Project Overview
|
||||
|
||||
This is a Visual FoxPro 9 project that interfaces with the GoMag e-commerce API. The main component is a script for retrieving product data from GoMag's REST API endpoints.
|
||||
This is a Visual FoxPro 9 project that interfaces with the GoMag e-commerce API. The application retrieves both product and order data from GoMag's REST API endpoints with full pagination support and comprehensive error handling.
|
||||
|
||||
## Architecture
|
||||
|
||||
- **Single File Application**: `gomag-vending.prg` - Main Visual FoxPro script
|
||||
- **Main Application**: `gomag-vending.prg` - Primary Visual FoxPro script with pagination support
|
||||
- **Utility Module**: `utils.prg` - INI file handling, logging, and helper functions
|
||||
- **JSON Library**: `nfjson/` - Third-party JSON parsing library for VFP
|
||||
- **Technology**: Visual FoxPro 9 with WinHttp.WinHttpRequest.5.1 for HTTP requests
|
||||
- **API Integration**: GoMag REST API v1 for product management
|
||||
- **API Integration**: GoMag REST API v1 for products and orders management
|
||||
|
||||
## Core Components
|
||||
|
||||
### gomag-vending.prg
|
||||
Main script that handles:
|
||||
- GoMag API authentication using Apikey and ApiShop headers
|
||||
- HTTP GET requests to retrieve product data
|
||||
- JSON response parsing and analysis
|
||||
- File output for API responses (timestamped .json files)
|
||||
- Error handling and connectivity testing
|
||||
Main application script with:
|
||||
- Complete pagination support for products and orders
|
||||
- Configurable API settings via INI file
|
||||
- Comprehensive error handling and logging
|
||||
- Rate limiting compliance (1-second delays between requests)
|
||||
- JSON array output generation for both products and orders
|
||||
|
||||
### Key Configuration Variables
|
||||
- `lcApiUrl`: GoMag API endpoint (defaults to product read endpoint)
|
||||
- `lcApiKey`: GoMag API key (must be configured)
|
||||
- `lcApiShop`: Shop URL (must be configured)
|
||||
### utils.prg
|
||||
Utility functions module containing:
|
||||
- INI file operations (`ReadPini`, `WritePini`, `LoadSettings`)
|
||||
- Logging system (`InitLog`, `LogMessage`, `CloseLog`)
|
||||
- Connectivity testing (`TestConnectivity`)
|
||||
- URL encoding utilities (`UrlEncode`)
|
||||
- Default configuration creation (`CreateDefaultIni`)
|
||||
|
||||
### settings.ini
|
||||
Configuration file with sections:
|
||||
- `[API]` - API endpoints, credentials, and headers
|
||||
- `[PAGINATION]` - Page size limits
|
||||
- `[OPTIONS]` - Feature toggles for products/orders retrieval
|
||||
- `[FILTERS]` - Date range filters for orders
|
||||
|
||||
## Development Commands
|
||||
|
||||
@@ -35,51 +47,84 @@ DO gomag-vending.prg
|
||||
```
|
||||
|
||||
### Running from Windows Command Line
|
||||
Use the provided batch file for easy execution:
|
||||
Use the provided batch file:
|
||||
```cmd
|
||||
run-gomag.bat
|
||||
```
|
||||
|
||||
Or directly with Visual FoxPro executable:
|
||||
Direct execution with Visual FoxPro:
|
||||
```cmd
|
||||
"C:\Program Files (x86)\Microsoft Visual FoxPro 9\vfp9.exe" -T "path\to\gomag-vending-test.prg"
|
||||
"C:\Program Files (x86)\Microsoft Visual FoxPro 9\vfp9.exe" -T "gomag-vending.prg"
|
||||
```
|
||||
|
||||
The batch file uses `%~dp0` to automatically detect the current directory, making it portable across different locations.
|
||||
## Configuration Management
|
||||
|
||||
### Testing Connectivity
|
||||
The script includes a `TestConnectivity()` function for internet connectivity testing.
|
||||
The application uses `settings.ini` for all configuration. Key settings:
|
||||
|
||||
### Required Configuration
|
||||
- `ApiKey` - Your GoMag API key
|
||||
- `ApiShop` - Your shop URL (e.g., "https://yourstore.gomag.ro")
|
||||
|
||||
### Feature Control
|
||||
- `GetProducts` - Set to "1" to retrieve products, "0" to skip
|
||||
- `GetOrders` - Set to "1" to retrieve orders, "0" to skip
|
||||
- `OrderDaysBack` - Number of days back to retrieve orders (default: 7)
|
||||
|
||||
### Pagination
|
||||
- `Limit` - Records per page (default: 100, max recommended for GoMag API)
|
||||
|
||||
## API Integration Details
|
||||
|
||||
### Authentication
|
||||
- Uses header-based authentication with `Apikey` and `ApiShop` headers
|
||||
- Requires User-Agent to be different from "PostmanRuntime"
|
||||
- Header-based authentication using `Apikey` and `ApiShop` headers
|
||||
- User-Agent must differ from "PostmanRuntime"
|
||||
|
||||
### Endpoints Used
|
||||
- Primary: `https://api.gomag.ro/api/v1/product/read/json?enabled=1`
|
||||
- Supports pagination, filtering by category/brand, and sorting parameters
|
||||
### Endpoints
|
||||
- Products: `https://api.gomag.ro/api/v1/product/read/json?enabled=1`
|
||||
- Orders: `https://api.gomag.ro/api/v1/order/read/json`
|
||||
|
||||
### Rate Limiting
|
||||
- No specific limitations for READ requests
|
||||
- POST requests limited to ~1 request per second (Leaky Bucket algorithm)
|
||||
- 1-second pause between paginated requests
|
||||
- No specific READ request limitations
|
||||
- POST requests limited to ~1 request per second (Leaky Bucket)
|
||||
|
||||
## Directory Structure
|
||||
|
||||
## File Structure
|
||||
```
|
||||
/
|
||||
├── gomag-vending-test.prg # Main application script
|
||||
├── run-gomag.bat # Windows batch file for easy execution
|
||||
└── gomag_products_*.json # Generated API response files (timestamped)
|
||||
├── gomag-vending.prg # Main application
|
||||
├── utils.prg # Utility functions
|
||||
├── settings.ini # Configuration file
|
||||
├── run-gomag.bat # Windows launcher
|
||||
├── nfjson/ # JSON parsing library
|
||||
│ ├── nfjsoncreate.prg
|
||||
│ └── nfjsonread.prg
|
||||
├── log/ # Generated log files
|
||||
├── output/ # Generated JSON files
|
||||
└── products-example.json # Sample API response
|
||||
```
|
||||
|
||||
## Configuration Requirements
|
||||
## Output Files
|
||||
|
||||
Before running, update these variables in `gomag-vending.prg:10-15`:
|
||||
1. `lcApiKey` - Your GoMag API key
|
||||
2. `lcApiShop` - Your shop URL (e.g., "https://yourstore.gomag.ro")
|
||||
### Generated Files
|
||||
- `log/gomag_sync_YYYYMMDD_HHMMSS.log` - Detailed execution logs
|
||||
- `output/gomag_all_products_YYYYMMDD_HHMMSS.json` - Complete product array
|
||||
- `output/gomag_orders_last7days_YYYYMMDD_HHMMSS.json` - Orders array
|
||||
|
||||
## Helper Functions
|
||||
### Error Files
|
||||
- `gomag_error_pageN_*.json` - Raw API responses for failed parsing
|
||||
- `gomag_error_pageN_*.log` - HTTP error details with status codes
|
||||
|
||||
- `ParseJsonResponse()` - Basic JSON structure analysis
|
||||
- `TestConnectivity()` - Internet connectivity testing
|
||||
- `UrlEncode()` - URL parameter encoding utility
|
||||
## Key Functions
|
||||
|
||||
### Main Application (gomag-vending.prg)
|
||||
- `SaveProductsArray` - Converts paginated product data to JSON array
|
||||
- `SaveOrdersArray` - Converts paginated order data to JSON array
|
||||
- `MergeProducts` - Combines products from multiple pages
|
||||
- `MergeOrdersArray` - Combines orders from multiple pages
|
||||
|
||||
### Utilities (utils.prg)
|
||||
- `LoadSettings` - Loads complete INI configuration into object
|
||||
- `InitLog`/`LogMessage`/`CloseLog` - Comprehensive logging system
|
||||
- `TestConnectivity` - Internet connection verification
|
||||
- `CreateDefaultIni` - Generates template configuration file
|
||||
Reference in New Issue
Block a user