Compare commits
121 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cec464ac2 | ||
|
|
1248772f60 | ||
|
|
165914d686 | ||
|
|
dbbdb3694b | ||
|
|
6ab5212a0f | ||
|
|
4ac5a148b6 | ||
|
|
5b91608577 | ||
|
|
2c54303189 | ||
|
|
123bd19e3c | ||
|
|
f0beb294ee | ||
|
|
a325a443f7 | ||
|
|
f05cc9215e | ||
|
|
162ef39013 | ||
|
|
ac57999a85 | ||
|
|
7d3d63db56 | ||
|
|
b9adb8c7d9 | ||
|
|
95b17b8776 | ||
|
|
1b3ebb3cad | ||
|
|
18d30a140f | ||
|
|
69fb1374b2 | ||
|
|
bbac8060b9 | ||
|
|
dba07fc5ff | ||
|
|
44abe3ed35 | ||
|
|
52f95bd677 | ||
|
|
6701dcd6bf | ||
|
|
9f0a77ca39 | ||
|
|
259243d44b | ||
|
|
84a57f3d98 | ||
|
|
ff25142f62 | ||
|
|
ebbea84a4c | ||
|
|
584def323c | ||
|
|
a8f46016be | ||
|
|
e0c9afe227 | ||
|
|
9094f3e3b7 | ||
|
|
867b2632df | ||
|
|
a69816baa4 | ||
|
|
e605af1231 | ||
|
|
e5a295faba | ||
|
|
5ec47b8332 | ||
|
|
122c7c8be4 | ||
|
|
6102194712 | ||
|
|
f0945ed431 | ||
|
|
b4b7a537e1 | ||
|
|
2d9e90c9a4 | ||
|
|
4e03d1e089 | ||
|
|
1f9c969e69 | ||
|
|
106316dc6d | ||
|
|
951d3a2a26 | ||
|
|
1248ba3f3a | ||
|
|
3b33e552a9 | ||
|
|
35531ff925 | ||
|
|
c4fa774a86 | ||
|
|
4b37d8c52c | ||
|
|
c320fe866d | ||
|
|
201f218c23 | ||
|
|
808f0eccc8 | ||
|
|
b8e4f4fd01 | ||
|
|
17c3fc57b2 | ||
|
|
87668e6dc0 | ||
|
|
68e49aab34 | ||
|
|
2944b52d43 | ||
|
|
325965bb10 | ||
|
|
48aec92794 | ||
|
|
82118a1fa8 | ||
|
|
233a682e35 | ||
|
|
9c292a9897 | ||
|
|
277bd1934e | ||
|
|
b7afe4f528 | ||
|
|
36c32c44d8 | ||
|
|
ea9b6c72e4 | ||
|
|
dbfbd53ad9 | ||
|
|
579db2231f | ||
|
|
9f289e4750 | ||
|
|
59347f504f | ||
|
|
13df12afc6 | ||
|
|
228aed6d58 | ||
|
|
c3a5d3bdbb | ||
|
|
b1be81023c | ||
|
|
6750a3d8a0 | ||
|
|
8a52765f87 | ||
|
|
eea25930ff | ||
|
|
a343013eed | ||
|
|
7380fa4378 | ||
|
|
642b6cb7a5 | ||
|
|
ebcf2c22dd | ||
|
|
373cf0882a | ||
|
|
6c2ce2dc08 | ||
|
|
7f25fb2b02 | ||
|
|
54c002ac96 | ||
|
|
382bf2334a | ||
|
|
06739ebea9 | ||
|
|
384fb2b558 | ||
|
|
8d4ccc4041 | ||
|
|
6688a9a465 | ||
|
|
12f245ae06 | ||
| 679785dd1c | |||
| 9eb993cba5 | |||
|
|
b79288f6b6 | ||
|
|
52114a7443 | ||
|
|
784ff0e5da | ||
| 0a6c4f64e8 | |||
|
|
958e48b40a | ||
|
|
76176f8a79 | ||
|
|
4416397a69 | ||
|
|
ff00edf35d | ||
|
|
7b539ea42f | ||
|
|
5fb313d4cc | ||
|
|
553fcc7a24 | ||
|
|
0f7f1532a0 | ||
|
|
4cfc00abb1 | ||
|
|
9f80f49693 | ||
|
|
e95b680ff0 | ||
|
|
4ceb50f9ed | ||
|
|
eda3bf505e | ||
|
|
d9f814ca64 | ||
|
|
06ea9caded | ||
|
|
2af9558b35 | ||
|
|
e9cf606dde | ||
|
|
7ed6ceecc5 | ||
|
|
31b6c7eceb | ||
|
|
85214344ef |
6
.env
Normal file
6
.env
Normal file
@@ -0,0 +1,6 @@
|
||||
# Environment variables for development
|
||||
# You can add project-specific environment variables here
|
||||
|
||||
# Example:
|
||||
# ALPINEBITS_CONFIG_DIR=./config
|
||||
# PYTHONPATH=./src
|
||||
143
.github/copilot-instructions.md
vendored
Normal file
143
.github/copilot-instructions.md
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
# AlpineBits Python Server - AI Agent Instructions
|
||||
|
||||
## Project Overview
|
||||
|
||||
This is an **AlpineBits 2024-10 server** that bridges booking requests from Wix landing pages to hotel partners. It's a dual-purpose system:
|
||||
|
||||
1. **FastAPI webhook receiver** - accepts booking forms from wix.com landing pages via `/api/webhook/wix-form`
|
||||
2. **AlpineBits OTA server** - exposes hotel reservation data at `/api/alpinebits/server-2024-10` using OpenTravel Alliance XML protocol
|
||||
|
||||
Data flows: Wix form → Database → AlpineBits XML → Hotel systems (pull or push)
|
||||
|
||||
## Architecture Patterns
|
||||
|
||||
### XML Generation with xsdata
|
||||
|
||||
- **Never manually construct XML strings**. Use xsdata-generated Pydantic dataclasses from `src/alpine_bits_python/generated/alpinebits.py`
|
||||
- Parse XML: `XmlParser().from_string(xml_string, OtaPingRq)`
|
||||
- Serialize XML: `XmlSerializer(config=SerializerConfig(...)).render(ota_object)`
|
||||
- Factory pattern: Use classes in `alpine_bits_helpers.py` (e.g., `CustomerFactory`, `GuestCountsFactory`) to build complex OTA objects from DB models
|
||||
- Example: `create_res_retrieve_response()` builds OTA_ResRetrieveRS from `(Reservation, Customer)` tuples
|
||||
- **Regenerating XML classes**: Run `xsdata` on `AlpineBits-HotelData-2024-10/files/schema-xsd/alpinebits.xsd` to regenerate `generated/alpinebits.py` (only if XSD spec changes)
|
||||
|
||||
### Configuration System
|
||||
|
||||
- Config loaded from YAML with secret injection via `!secret` tags (see `config_loader.py`)
|
||||
- Default config location: `config/config.yaml` + `config/secrets.yaml`
|
||||
- Override via `ALPINEBITS_CONFIG_DIR` environment variable
|
||||
- Multi-hotel support: Each hotel in `alpine_bits_auth` array gets own credentials and optional `push_endpoint`
|
||||
- **Logging**: Centralized logging configured via `logger` section (see `logging_config.py` and `LOGGING.md`)
|
||||
- Use `from logging_config import get_logger; _LOGGER = get_logger(__name__)` in any module
|
||||
- Logs to console always; optionally to file if `logger.file` is set
|
||||
- Format includes timestamp: `%(asctime)s - %(name)s - %(levelname)s - %(message)s`
|
||||
|
||||
### Database Layer
|
||||
|
||||
- **Async-only SQLAlchemy** with `AsyncSession` (see `db.py`)
|
||||
- Three core tables: `Customer`, `Reservation`, `AckedRequest` (tracks which clients acknowledged which reservations)
|
||||
- DB URL configurable: SQLite for dev (`sqlite+aiosqlite:///alpinebits.db`), PostgreSQL for prod
|
||||
- Database auto-created on startup in `api.py:create_app()`
|
||||
|
||||
### Event-Driven Push System
|
||||
|
||||
- `EventDispatcher` in `api.py` enables hotel-specific listeners: `event_dispatcher.register_hotel_listener("reservation:created", hotel_code, push_listener)`
|
||||
- Push listener sends OTA_HotelResNotif XML to hotel's configured `push_endpoint.url` with Bearer token auth
|
||||
- Push requests logged to `logs/push_requests/` with timestamp and unique ID
|
||||
- **Note**: Push endpoint support is currently dormant - configured but not actively used by partners
|
||||
|
||||
### AlpineBits Action Pattern
|
||||
|
||||
- Each OTA action is a class inheriting `AlpineBitsActionHandler` (see `alpinebits_server.py`)
|
||||
- Actions: `PingAction`, `ReadAction`, `NotifReportAction`, `PushAction`
|
||||
- Request flow: Parse XML → Call `handle()` → Return `AlpineBitsActionResult` with XML response + HTTP status
|
||||
- `AlpineBitsActionName` enum maps capability names to request names (e.g., `OTA_READ` → `"OTA_Read:GuestRequests"`)
|
||||
- Server supports multiple AlpineBits versions (2024-10, 2022-10) when actions are identical across versions
|
||||
|
||||
### Acknowledgment System
|
||||
|
||||
- `AckedRequest` table tracks which clients acknowledged which reservations via `OTA_NotifReport:GuestRequests`
|
||||
- Read requests filter out acknowledged reservations for clients with `client_id`
|
||||
- Prevents duplicate reservation sends: once acknowledged, data won't appear in subsequent reads for that client
|
||||
|
||||
## Critical Workflows
|
||||
|
||||
### Running Locally
|
||||
|
||||
```bash
|
||||
uv sync # Install dependencies (uses uv, not pip!)
|
||||
uv run python -m alpine_bits_python.run_api # Start server on port 8080, clears DB on startup
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
uv run pytest # Run all tests
|
||||
uv run pytest tests/test_alpine_bits_server_read.py # Specific test file
|
||||
```
|
||||
|
||||
- Tests use in-memory SQLite via `test_db_engine` fixture (see `tests/test_alpine_bits_server_read.py`)
|
||||
- Test data fixtures in `tests/test_data/` directory
|
||||
|
||||
### Building for Deployment
|
||||
|
||||
```bash
|
||||
uv sync
|
||||
docker build . -t gitea.linter-home.com/jonas/asa_api:master
|
||||
```
|
||||
|
||||
- Multi-stage Dockerfile: builder stage installs deps with uv, production stage copies `.venv`
|
||||
- Runs as non-root user (UID 1000) for security
|
||||
- Requires `ALPINEBITS_CONFIG_DIR=/config` volume mount for config files
|
||||
- **Deployment**: Docker build pipeline exists and works; can also build manually on target system
|
||||
|
||||
## Project-Specific Conventions
|
||||
|
||||
### Naming Patterns
|
||||
|
||||
- OTA message types use full AlpineBits names: `OtaReadRq`, `OtaResRetrieveRs`, `OtaHotelResNotifRq`
|
||||
- Factory classes suffix with `Factory`: `CustomerFactory`, `HotelReservationIdFactory`
|
||||
- DB models in `db.py`, validation schemas in `schemas.py`, OTA helpers in `alpine_bits_helpers.py`
|
||||
|
||||
### Data Validation Flow
|
||||
|
||||
1. **API Layer** → Pydantic schemas (`schemas.py`) validate incoming data
|
||||
2. **DB Layer** → SQLAlchemy models (`db.py`) persist validated data
|
||||
3. **XML Layer** → xsdata classes (`generated/alpinebits.py`) + factories (`alpine_bits_helpers.py`) generate OTA XML
|
||||
|
||||
This separation prevents mixing concerns (validation ≠ persistence ≠ XML generation).
|
||||
|
||||
### Unique ID Generation
|
||||
|
||||
- Reservation IDs: 35-char max, format `{hotel_code}_{uuid4}_{timestamp}`
|
||||
- Generated via `generate_unique_id()` in `auth.py`
|
||||
|
||||
### Rate Limiting
|
||||
|
||||
- Uses `slowapi` with Redis backend
|
||||
- Three tiers: `DEFAULT_RATE_LIMIT` (100/hour), `WEBHOOK_RATE_LIMIT` (300/hour), `BURST_RATE_LIMIT` (10/minute)
|
||||
- Applied via decorators: `@limiter.limit(DEFAULT_RATE_LIMIT)`
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
1. **Don't use synchronous SQLAlchemy calls** - Always `await session.execute()`, never `session.query()`
|
||||
2. **Don't hardcode XML namespaces** - Let xsdata handle them via generated classes
|
||||
3. **Don't skip config validation** - Voluptuous schemas in `config_loader.py` catch config errors early
|
||||
4. **Auth is per-hotel** - HTTP Basic Auth credentials from `alpine_bits_auth` config array
|
||||
5. **AlpineBits version matters** - Server implements 2024-10 spec (see `AlpineBits-HotelData-2024-10/` directory)
|
||||
|
||||
## Key Files Reference
|
||||
|
||||
- `api.py` - FastAPI app, all endpoints, event dispatcher
|
||||
- `alpinebits_server.py` - AlpineBits action handlers (Ping, Read, NotifReport)
|
||||
- `alpine_bits_helpers.py` - Factory classes for building OTA XML from DB models
|
||||
- `config_loader.py` - YAML config loading with secret injection
|
||||
- `db.py` - SQLAlchemy async models (Customer, Reservation, AckedRequest)
|
||||
- `schemas.py` - Pydantic validation schemas
|
||||
- `generated/alpinebits.py` - xsdata-generated OTA XML classes (DO NOT EDIT - regenerate from XSD)
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
- Fixtures create isolated in-memory databases per test
|
||||
- Use `test_config()` fixture for test configuration
|
||||
- XML serialization/parsing tested via xsdata round-trips
|
||||
- Push endpoint mocking via httpx in tests
|
||||
88
.github/workflows/build.yaml
vendored
Normal file
88
.github/workflows/build.yaml
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
name: CI to Docker Hub
|
||||
|
||||
# Controls when the workflow will run
|
||||
on:
|
||||
# Triggers the workflow on push or pull request events but only for the main branch
|
||||
push:
|
||||
branches: [ "*" ]
|
||||
tags: [ "*" ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
build:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
|
||||
- name: UV sync
|
||||
run: uv auth login gitea.linter-home.com --username jonas --password ${{ secrets.CI_TOKEN }} && uv lock
|
||||
|
||||
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Login to Gitea Docker Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ vars.REGISTRY }}
|
||||
username: ${{ vars.USER_NAME }}
|
||||
password: ${{ secrets.CI_TOKEN }}
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ vars.REGISTRY }}/${{ vars.USER_NAME }}/asa_api
|
||||
# generate Docker tags based on the following events/attributes
|
||||
tags: |
|
||||
type=schedule
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=ref,event=tag
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=sha
|
||||
|
||||
# - name: Debug DNS Resolution
|
||||
# run: sudo apt-get update && sudo apt-get install -y dnsutils &&
|
||||
# nslookup https://${{ vars.REGISTRY }}
|
||||
|
||||
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
registry: ${{ vars.REGISTRY }}
|
||||
username: ${{ vars.USER_NAME }}
|
||||
password: ${{ secrets.CI_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
build-args: |
|
||||
CI_TOKEN=${{ secrets.CI_TOKEN }}
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||
10
.github/workflows/publish.yaml
vendored
10
.github/workflows/publish.yaml
vendored
@@ -13,15 +13,11 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v6
|
||||
uses: astral-sh/setup-uv@v5
|
||||
- name: Install Python 3.13
|
||||
run: uv python install 3.13
|
||||
- name: Build
|
||||
run: uv build
|
||||
run: uv auth login gitea.linter-home.com --username jonas --password ${{ secrets.CI_TOKEN }} && uv build
|
||||
# Check that basic features work and we didn't miss to include crucial files
|
||||
- name: Smoke test (wheel)
|
||||
run: uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py
|
||||
- name: Smoke test (source distribution)
|
||||
run: uv run --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py
|
||||
- name: Publish
|
||||
run: uv publish --publish-url https://gitea.linter-home.com.com/api/packages/jonas/pypi --username jonas --password ${{ secrets.GITEA_TOKEN }}
|
||||
run: uv publish --publish-url https://gitea.linter-home.com/api/packages/jonas/pypi --username jonas --password ${{ secrets.CI_TOKEN }}
|
||||
18
.gitignore
vendored
18
.gitignore
vendored
@@ -13,3 +13,21 @@ wheels/
|
||||
|
||||
# exclude ruff cache
|
||||
.ruff_cache/
|
||||
|
||||
# ignore test_data content but keep the folder
|
||||
test_data/*
|
||||
|
||||
test/test_output/*
|
||||
|
||||
logs/*
|
||||
|
||||
|
||||
# ignore secrets
|
||||
secrets.yaml
|
||||
|
||||
# ignore db
|
||||
alpinebits.db
|
||||
|
||||
# test output files
|
||||
test_output.txt
|
||||
output.xml
|
||||
|
||||
38
.vscode/launch.json
vendored
Normal file
38
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: Debug Tests",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "${file}",
|
||||
"purpose": [
|
||||
"debug-test"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false,
|
||||
"env": {
|
||||
"PYTEST_ADDOPTS": "--no-cov"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Python: Current File",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "${file}",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true
|
||||
},
|
||||
{
|
||||
"name": "Python: API Server",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"module": "alpine_bits_python.run_api",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true,
|
||||
"env": {
|
||||
"ALPINEBITS_CONFIG_DIR": "${workspaceFolder}/config"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
59
.vscode/settings.json
vendored
59
.vscode/settings.json
vendored
@@ -1,7 +1,56 @@
|
||||
{
|
||||
"python.testing.pytestArgs": [
|
||||
"test"
|
||||
],
|
||||
"python.testing.unittestEnabled": false,
|
||||
"python.testing.pytestEnabled": true
|
||||
"editor.formatOnSave": true,
|
||||
"[python]": {
|
||||
"editor.defaultFormatter": "charliermarsh.ruff",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll": "explicit",
|
||||
"source.organizeImports": "explicit"
|
||||
}
|
||||
},
|
||||
"[json]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"notebook.formatOnSave.enabled": true,
|
||||
"notebook.codeActionsOnSave": {
|
||||
// "notebook.source.fixAll": "explicit",
|
||||
// "notebook.source.organizeImports": "explicit"
|
||||
},
|
||||
"notebook.output.wordWrap": true,
|
||||
"notebook.output.textLineLimit": 200,
|
||||
"jupyter.debugJustMyCode": false,
|
||||
"python.defaultInterpreterPath": "./.venv/bin/python",
|
||||
"python.terminal.activateEnvironment": true,
|
||||
"python.terminal.activateEnvInCurrentTerminal": true,
|
||||
"python.envFile": "${workspaceFolder}/.env",
|
||||
"terminal.integrated.env.linux": {
|
||||
"VIRTUAL_ENV": "${workspaceFolder}/.venv",
|
||||
"PATH": "${workspaceFolder}/.venv/bin:${env:PATH}"
|
||||
},
|
||||
"terminal.integrated.defaultProfile.linux": "bash",
|
||||
"terminal.integrated.profiles.linux": {
|
||||
"bash": {
|
||||
"path": "bash",
|
||||
"args": ["-c", "source ${workspaceFolder}/.venv/bin/activate && exec bash"]
|
||||
}
|
||||
},
|
||||
"python.testing.pytestEnabled": true,
|
||||
"python.testing.pytestArgs": [
|
||||
"tests",
|
||||
"-v",
|
||||
"--tb=short"
|
||||
],
|
||||
"python.testing.pytestPath": "./.venv/bin/pytest",
|
||||
"python.testing.unittestEnabled": false,
|
||||
"python.testing.autoTestDiscoverOnSaveEnabled": true,
|
||||
"python.testing.cwd": "${workspaceFolder}",
|
||||
"files.exclude": {
|
||||
"**/*.egg-info": true,
|
||||
"**/htmlcov": true,
|
||||
"**/~$*": true,
|
||||
"**/.coverage.*": true,
|
||||
"**/.venv": true,
|
||||
"**/__pycache__": true,
|
||||
"**/.mypy_cache": true,
|
||||
"**/.pytest_cache": true
|
||||
}
|
||||
}
|
||||
24
99Tales_Testexport.xml
Normal file
24
99Tales_Testexport.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<reservations>
|
||||
<reservation id="2409" number="191" date="2025-08-28" creationTime="2025-08-28T11:53:45" type="reservation" bookingGroup="" bookingChannel="99TALES" advertisingMedium="99TALES" advertisingPartner="399">
|
||||
<guest id="364" lastName="Busch" firstName="Sebastian" language="de" gender="male" dateOfBirth="" postalCode="58454" city="Witten" countryCode="DE" country="DEUTSCHLAND" email="test@test.com"/>
|
||||
<company/>
|
||||
<roomReservations>
|
||||
<roomReservation arrival="2025-09-03" departure="2025-09-12" status="reserved" roomType="EZ" roomNumber="106" adults="1" children="0" infants="0" ratePlanCode="WEEK" connectedRoomType="0">
|
||||
<connectedRooms/>
|
||||
<dailySales>
|
||||
<dailySale date="2025-09-03" revenueTotal="174" revenueLogis="127.5" revenueBoard="9" revenueFB="10" revenueSpa="1" revenueOther="26.5" revenueResources=""/>
|
||||
<dailySale date="2025-09-04" revenueTotal="164" revenueLogis="127.5" revenueBoard="9" revenueFB="10" revenueSpa="1" revenueOther="16.5" revenueResources=""/>
|
||||
<dailySale date="2025-09-05" revenueTotal="164" revenueLogis="127.5" revenueBoard="9" revenueFB="10" revenueSpa="1" revenueOther="16.5" revenueResources=""/>
|
||||
<dailySale date="2025-09-06" revenueTotal="164" revenueLogis="127.5" revenueBoard="9" revenueFB="10" revenueSpa="1" revenueOther="16.5" revenueResources=""/>
|
||||
<dailySale date="2025-09-07" revenueTotal="164" revenueLogis="127.5" revenueBoard="9" revenueFB="10" revenueSpa="1" revenueOther="16.5" revenueResources=""/>
|
||||
<dailySale date="2025-09-08" revenueTotal="164" revenueLogis="127.5" revenueBoard="9" revenueFB="10" revenueSpa="1" revenueOther="16.5" revenueResources=""/>
|
||||
<dailySale date="2025-09-09" revenueTotal="164" revenueLogis="127.5" revenueBoard="9" revenueFB="10" revenueSpa="1" revenueOther="16.5" revenueResources=""/>
|
||||
<dailySale date="2025-09-10" revenueTotal="164" revenueLogis="127.5" revenueBoard="9" revenueFB="10" revenueSpa="1" revenueOther="16.5" revenueResources=""/>
|
||||
<dailySale date="2025-09-11" revenueTotal="149" revenueLogis="127.5" revenueBoard="9" revenueFB="10" revenueSpa="1" revenueOther="1.5" revenueResources=""/>
|
||||
<dailySale date="2025-09-12" revenueTotal="" revenueLogis="" revenueBoard="" revenueFB="" revenueSpa="" revenueOther="" revenueResources=""/>
|
||||
</dailySales>
|
||||
</roomReservation>
|
||||
</roomReservations>
|
||||
</reservation>
|
||||
</reservations>
|
||||
@@ -1,59 +0,0 @@
|
||||
## AlpineBits Action Mapping System
|
||||
|
||||
### Problem Solved
|
||||
The AlpineBits specification uses different names for the same action:
|
||||
- **Capability JSON**: `"action_OTA_Read"` (advertised in handshake)
|
||||
- **Request Action**: `"OTA_Read:GuestRequests"` (actual request parameter)
|
||||
|
||||
### Solution Architecture
|
||||
|
||||
#### 1. Enhanced AlpineBitsActionName Enum
|
||||
```python
|
||||
# Maps capability names to request names
|
||||
OTA_READ = ("action_OTA_Read", ["OTA_Read:GuestRequests", "OTA_Read"])
|
||||
```
|
||||
|
||||
#### 2. Automatic Action Discovery
|
||||
- `ServerCapabilities` scans for implemented actions
|
||||
- Only includes actions with overridden `handle()` methods
|
||||
- Generates capability JSON using capability names
|
||||
|
||||
#### 3. Request Routing
|
||||
- `AlpineBitsServer.handle_request()` accepts request action names
|
||||
- Maps request names back to capability names
|
||||
- Routes to appropriate action handler
|
||||
- Validates version support
|
||||
|
||||
### Key Features
|
||||
|
||||
✅ **Automatic Discovery**: New action implementations are automatically detected
|
||||
✅ **Name Mapping**: Handles capability vs request name differences
|
||||
✅ **Version Support**: Actions can support multiple versions
|
||||
✅ **Error Handling**: Proper HTTP status codes (200, 400, 401, 500)
|
||||
✅ **Capability Generation**: Dynamic JSON generation for handshakes
|
||||
|
||||
### Usage Example
|
||||
|
||||
```python
|
||||
# Server automatically discovers implemented actions
|
||||
server = AlpineBitsServer()
|
||||
|
||||
# Handle request with different name format
|
||||
response = await server.handle_request(
|
||||
"OTA_Read:GuestRequests", # Request name
|
||||
xml_content,
|
||||
"2024-10"
|
||||
)
|
||||
|
||||
# Capability JSON uses "action_OTA_Read" automatically
|
||||
capabilities = server.get_capabilities_json()
|
||||
```
|
||||
|
||||
### Adding New Actions
|
||||
|
||||
1. Create action class inheriting from `AlpineBitsAction`
|
||||
2. Add mapping to `AlpineBitsActionName` enum
|
||||
3. Implement `handle()` method
|
||||
4. Deploy - action automatically appears in capabilities
|
||||
|
||||
The system is now production-ready for handling AlpineBits protocol quirks!
|
||||
Binary file not shown.
1
CLAUDE.md
Normal file
1
CLAUDE.md
Normal file
@@ -0,0 +1 @@
|
||||
This python project is managed by uv. Use uv run to execute app and tests.
|
||||
@@ -1,93 +0,0 @@
|
||||
class GivenNameType(GeneratedsSuper):
|
||||
__hash__ = GeneratedsSuper.__hash__
|
||||
subclass = None
|
||||
superclass = None
|
||||
def __init__(self, valueOf_=None, gds_collector_=None, **kwargs_):
|
||||
self.gds_collector_ = gds_collector_
|
||||
self.gds_elementtree_node_ = None
|
||||
self.original_tagname_ = None
|
||||
self.parent_object_ = kwargs_.get('parent_object_')
|
||||
self.ns_prefix_ = None
|
||||
self.valueOf_ = valueOf_
|
||||
def factory(*args_, **kwargs_):
|
||||
if CurrentSubclassModule_ is not None:
|
||||
subclass = getSubclassFromModule_(
|
||||
CurrentSubclassModule_, GivenNameType)
|
||||
if subclass is not None:
|
||||
return subclass(*args_, **kwargs_)
|
||||
if GivenNameType.subclass:
|
||||
return GivenNameType.subclass(*args_, **kwargs_)
|
||||
else:
|
||||
return GivenNameType(*args_, **kwargs_)
|
||||
factory = staticmethod(factory)
|
||||
def get_ns_prefix_(self):
|
||||
return self.ns_prefix_
|
||||
def set_ns_prefix_(self, ns_prefix):
|
||||
self.ns_prefix_ = ns_prefix
|
||||
def get_valueOf_(self): return self.valueOf_
|
||||
def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
|
||||
def validate_StringLength1to64(self, value):
|
||||
result = True
|
||||
# Validate type StringLength1to64, a restriction on xs:string.
|
||||
if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
|
||||
if not isinstance(value, str):
|
||||
lineno = self.gds_get_node_lineno_()
|
||||
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
|
||||
return False
|
||||
if len(value) > 64:
|
||||
lineno = self.gds_get_node_lineno_()
|
||||
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on StringLength1to64' % {"value" : encode_str_2_3(value), "lineno": lineno} )
|
||||
result = False
|
||||
if len(value) < 1:
|
||||
lineno = self.gds_get_node_lineno_()
|
||||
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on StringLength1to64' % {"value" : encode_str_2_3(value), "lineno": lineno} )
|
||||
result = False
|
||||
return result
|
||||
def has__content(self):
|
||||
if (
|
||||
(1 if type(self.valueOf_) in [int,float] else self.valueOf_)
|
||||
):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='GivenNameType', pretty_print=True):
|
||||
imported_ns_def_ = GenerateDSNamespaceDefs_.get('GivenNameType')
|
||||
if imported_ns_def_ is not None:
|
||||
namespacedef_ = imported_ns_def_
|
||||
if pretty_print:
|
||||
eol_ = '\n'
|
||||
else:
|
||||
eol_ = ''
|
||||
if self.original_tagname_ is not None and name_ == 'GivenNameType':
|
||||
name_ = self.original_tagname_
|
||||
if UseCapturedNS_ and self.ns_prefix_:
|
||||
namespaceprefix_ = self.ns_prefix_ + ':'
|
||||
showIndent(outfile, level, pretty_print)
|
||||
outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
|
||||
already_processed = set()
|
||||
self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='GivenNameType')
|
||||
outfile.write('>')
|
||||
self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_, pretty_print=pretty_print)
|
||||
outfile.write(self.convert_unicode(self.valueOf_))
|
||||
outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
|
||||
def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='GivenNameType'):
|
||||
pass
|
||||
def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='GivenNameType', fromsubclass_=False, pretty_print=True):
|
||||
pass
|
||||
def build(self, node, gds_collector_=None):
|
||||
self.gds_collector_ = gds_collector_
|
||||
if SaveElementTreeNode:
|
||||
self.gds_elementtree_node_ = node
|
||||
already_processed = set()
|
||||
self.ns_prefix_ = node.prefix
|
||||
self._buildAttributes(node, node.attrib, already_processed)
|
||||
self.valueOf_ = get_all_text_(node)
|
||||
for child in node:
|
||||
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
|
||||
self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
|
||||
return self
|
||||
def _buildAttributes(self, node, attrs, already_processed):
|
||||
pass
|
||||
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
|
||||
pass
|
||||
# end class GivenNameType
|
||||
@@ -1,93 +0,0 @@
|
||||
class SurnameType(GeneratedsSuper):
|
||||
__hash__ = GeneratedsSuper.__hash__
|
||||
subclass = None
|
||||
superclass = None
|
||||
def __init__(self, valueOf_=None, gds_collector_=None, **kwargs_):
|
||||
self.gds_collector_ = gds_collector_
|
||||
self.gds_elementtree_node_ = None
|
||||
self.original_tagname_ = None
|
||||
self.parent_object_ = kwargs_.get('parent_object_')
|
||||
self.ns_prefix_ = None
|
||||
self.valueOf_ = valueOf_
|
||||
def factory(*args_, **kwargs_):
|
||||
if CurrentSubclassModule_ is not None:
|
||||
subclass = getSubclassFromModule_(
|
||||
CurrentSubclassModule_, SurnameType)
|
||||
if subclass is not None:
|
||||
return subclass(*args_, **kwargs_)
|
||||
if SurnameType.subclass:
|
||||
return SurnameType.subclass(*args_, **kwargs_)
|
||||
else:
|
||||
return SurnameType(*args_, **kwargs_)
|
||||
factory = staticmethod(factory)
|
||||
def get_ns_prefix_(self):
|
||||
return self.ns_prefix_
|
||||
def set_ns_prefix_(self, ns_prefix):
|
||||
self.ns_prefix_ = ns_prefix
|
||||
def get_valueOf_(self): return self.valueOf_
|
||||
def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
|
||||
def validate_StringLength1to64(self, value):
|
||||
result = True
|
||||
# Validate type StringLength1to64, a restriction on xs:string.
|
||||
if value is not None and Validate_simpletypes_ and self.gds_collector_ is not None:
|
||||
if not isinstance(value, str):
|
||||
lineno = self.gds_get_node_lineno_()
|
||||
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s is not of the correct base simple type (str)' % {"value": value, "lineno": lineno, })
|
||||
return False
|
||||
if len(value) > 64:
|
||||
lineno = self.gds_get_node_lineno_()
|
||||
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd maxLength restriction on StringLength1to64' % {"value" : encode_str_2_3(value), "lineno": lineno} )
|
||||
result = False
|
||||
if len(value) < 1:
|
||||
lineno = self.gds_get_node_lineno_()
|
||||
self.gds_collector_.add_message('Value "%(value)s"%(lineno)s does not match xsd minLength restriction on StringLength1to64' % {"value" : encode_str_2_3(value), "lineno": lineno} )
|
||||
result = False
|
||||
return result
|
||||
def has__content(self):
|
||||
if (
|
||||
(1 if type(self.valueOf_) in [int,float] else self.valueOf_)
|
||||
):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
def export(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='SurnameType', pretty_print=True):
|
||||
imported_ns_def_ = GenerateDSNamespaceDefs_.get('SurnameType')
|
||||
if imported_ns_def_ is not None:
|
||||
namespacedef_ = imported_ns_def_
|
||||
if pretty_print:
|
||||
eol_ = '\n'
|
||||
else:
|
||||
eol_ = ''
|
||||
if self.original_tagname_ is not None and name_ == 'SurnameType':
|
||||
name_ = self.original_tagname_
|
||||
if UseCapturedNS_ and self.ns_prefix_:
|
||||
namespaceprefix_ = self.ns_prefix_ + ':'
|
||||
showIndent(outfile, level, pretty_print)
|
||||
outfile.write('<%s%s%s' % (namespaceprefix_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
|
||||
already_processed = set()
|
||||
self._exportAttributes(outfile, level, already_processed, namespaceprefix_, name_='SurnameType')
|
||||
outfile.write('>')
|
||||
self._exportChildren(outfile, level + 1, namespaceprefix_, namespacedef_, name_, pretty_print=pretty_print)
|
||||
outfile.write(self.convert_unicode(self.valueOf_))
|
||||
outfile.write('</%s%s>%s' % (namespaceprefix_, name_, eol_))
|
||||
def _exportAttributes(self, outfile, level, already_processed, namespaceprefix_='', name_='SurnameType'):
|
||||
pass
|
||||
def _exportChildren(self, outfile, level, namespaceprefix_='', namespacedef_='', name_='SurnameType', fromsubclass_=False, pretty_print=True):
|
||||
pass
|
||||
def build(self, node, gds_collector_=None):
|
||||
self.gds_collector_ = gds_collector_
|
||||
if SaveElementTreeNode:
|
||||
self.gds_elementtree_node_ = node
|
||||
already_processed = set()
|
||||
self.ns_prefix_ = node.prefix
|
||||
self._buildAttributes(node, node.attrib, already_processed)
|
||||
self.valueOf_ = get_all_text_(node)
|
||||
for child in node:
|
||||
nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
|
||||
self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_)
|
||||
return self
|
||||
def _buildAttributes(self, node, attrs, already_processed):
|
||||
pass
|
||||
def _buildChildren(self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None):
|
||||
pass
|
||||
# end class SurnameType
|
||||
66
Dockerfile
Normal file
66
Dockerfile
Normal file
@@ -0,0 +1,66 @@
|
||||
# Multi-stage build for smaller final image
|
||||
FROM python:3.13-slim AS builder
|
||||
|
||||
# Install uv for fast dependency management
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependency files
|
||||
COPY pyproject.toml uv.lock README.md ./
|
||||
|
||||
ARG CI_TOKEN
|
||||
|
||||
# Install dependencies in a virtual environment
|
||||
RUN uv sync --frozen --no-cache
|
||||
|
||||
# Production stage
|
||||
FROM python:3.13-slim
|
||||
|
||||
# Create non-root user for security
|
||||
RUN groupadd -r appuser && useradd -r -g appuser -u 1000 appuser
|
||||
|
||||
# Install uv in production image
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy virtual environment from builder stage
|
||||
COPY --from=builder /app/.venv /app/.venv
|
||||
|
||||
# Copy application code
|
||||
COPY src/ ./src/
|
||||
|
||||
# Create directories and set permissions
|
||||
RUN mkdir -p /app/logs && \
|
||||
chown -R appuser:appuser /app
|
||||
|
||||
# Switch to non-root user
|
||||
USER appuser
|
||||
|
||||
# Set environment variables
|
||||
ENV PATH="/app/.venv/bin:$PATH" \
|
||||
PYTHONPATH="/app/src" \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
|
||||
# Expose port (non-privileged port)
|
||||
EXPOSE 8000
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=120s --timeout=10s --start-period=60s --retries=3 \
|
||||
CMD python -c "import requests; requests.get('http://localhost:8000/api/health', timeout=5)"
|
||||
|
||||
# Run the application with uvicorn
|
||||
WORKDIR /app/src
|
||||
CMD uvicorn alpine_bits_python.api:app \
|
||||
--host 0.0.0.0 \
|
||||
--port 8000 \
|
||||
--workers 4 \
|
||||
--log-level info \
|
||||
--access-log \
|
||||
--forwarded-allow-ips "${FORWARDED_ALLOW_IPS:-127.0.0.1}" \
|
||||
--proxy-headers \
|
||||
--no-server-header
|
||||
118
LOGGING.md
Normal file
118
LOGGING.md
Normal file
@@ -0,0 +1,118 @@
|
||||
# Logging Configuration
|
||||
|
||||
The AlpineBits Python server uses a centralized logging system that can be configured via the `config.yaml` file.
|
||||
|
||||
## Configuration
|
||||
|
||||
Add the following section to your `config/config.yaml`:
|
||||
|
||||
```yaml
|
||||
logger:
|
||||
level: "INFO" # Options: DEBUG, INFO, WARNING, ERROR, CRITICAL
|
||||
file: "logs/alpinebits.log" # Optional: path to log file (omit or set to null for console-only)
|
||||
```
|
||||
|
||||
### Log Levels
|
||||
|
||||
- **DEBUG**: Detailed diagnostic information (very verbose)
|
||||
- **INFO**: General informational messages about application progress
|
||||
- **WARNING**: Warning messages about potential issues
|
||||
- **ERROR**: Error messages when something goes wrong
|
||||
- **CRITICAL**: Critical errors that may cause application failure
|
||||
|
||||
### Log Output
|
||||
|
||||
- **Console**: Logs are always written to console (stdout)
|
||||
- **File**: Optionally write logs to a file by specifying the `file` parameter
|
||||
- File logs include the same timestamp and formatting as console logs
|
||||
- Log directory will be created automatically if it doesn't exist
|
||||
|
||||
## Usage in Code
|
||||
|
||||
To use logging in any module:
|
||||
|
||||
```python
|
||||
from alpine_bits_python.logging_config import get_logger
|
||||
|
||||
_LOGGER = get_logger(__name__)
|
||||
|
||||
# Then use the logger
|
||||
_LOGGER.info("Application started")
|
||||
_LOGGER.debug("Detailed debug information: %s", some_variable)
|
||||
_LOGGER.warning("Something unusual happened")
|
||||
_LOGGER.error("An error occurred: %s", error_message)
|
||||
_LOGGER.exception("Critical error with stack trace")
|
||||
```
|
||||
|
||||
## Log Format
|
||||
|
||||
All log entries include:
|
||||
|
||||
- Timestamp (YYYY-MM-DD HH:MM:SS)
|
||||
- Module name (logger name)
|
||||
- Log level
|
||||
- Message
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
2025-10-09 14:23:45 - alpine_bits_python.api - INFO - Application startup initiated
|
||||
2025-10-09 14:23:45 - alpine_bits_python.api - INFO - Logging configured at INFO level
|
||||
2025-10-09 14:23:46 - alpine_bits_python.api - INFO - Database tables checked/created at startup.
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use structured logging**: Pass variables as arguments, not f-strings
|
||||
|
||||
```python
|
||||
# Good
|
||||
_LOGGER.info("Processing reservation %s for hotel %s", reservation_id, hotel_code)
|
||||
|
||||
# Avoid (performance overhead, linting warnings)
|
||||
_LOGGER.info(f"Processing reservation {reservation_id} for hotel {hotel_code}")
|
||||
```
|
||||
|
||||
2. **Use appropriate log levels**:
|
||||
|
||||
- `DEBUG`: Detailed tracing for development
|
||||
- `INFO`: Normal application flow events
|
||||
- `WARNING`: Unexpected but handled situations
|
||||
- `ERROR`: Errors that need attention
|
||||
- `CRITICAL`: Severe errors requiring immediate action
|
||||
|
||||
3. **Use `exception()` for error handling**:
|
||||
|
||||
```python
|
||||
try:
|
||||
risky_operation()
|
||||
except Exception:
|
||||
_LOGGER.exception("Operation failed") # Automatically includes stack trace
|
||||
```
|
||||
|
||||
4. **Don't log sensitive data**: Avoid logging passwords, tokens, or personal data
|
||||
|
||||
## Examples
|
||||
|
||||
### Console-only logging (development)
|
||||
|
||||
```yaml
|
||||
logger:
|
||||
level: "DEBUG"
|
||||
```
|
||||
|
||||
### File logging (production)
|
||||
|
||||
```yaml
|
||||
logger:
|
||||
level: "INFO"
|
||||
file: "/var/log/alpinebits/app.log"
|
||||
```
|
||||
|
||||
### Minimal logging
|
||||
|
||||
```yaml
|
||||
logger:
|
||||
level: "WARNING"
|
||||
file: "logs/warnings.log"
|
||||
```
|
||||
182
README.md
182
README.md
@@ -1,10 +1,182 @@
|
||||
# Alpine bits
|
||||
# Übersicht
|
||||
|
||||
Enthält einen in Python geschriebenen Alpine Bits Server zur Übertragung von Buchungsanfragen von Landingpages an Partnerhotels. Ein Fastapi Endpoint empfängt Anfrageformulare von den wix.com landingpages, und speichert sie in die Datenbank ab. Der Alpine Bits Server stellt diese dann Hotels auf dem Endpoint `www.99tales.net/api/alpinebits/server-2024-10` zu Verfügung.
|
||||
|
||||
|
||||
## Entwicklung
|
||||
|
||||
Auf dem Entwicklungsystem muss git und der uv python package manager installiert sein.
|
||||
|
||||
### Git Authentification
|
||||
|
||||
Wenn über http geklont wird muss lokal der [git-credential-oauth](https://github.com/hickford/git-credential-oauth) helper installiert sein. Besser gehts über ssh. Da muss ein ssh-key in gitea für den eigenen Benutzer angelegt sein.
|
||||
|
||||
1. Repo klonen.
|
||||
2. `uv sync` ausführen
|
||||
3. `uv run python -m alpine_bits_python.run_api` führt die API lokal auf Port 8080 aus. Datenbank wird automatisch erstellt und bei jedem start geleert.
|
||||
|
||||
## Konfiguration
|
||||
|
||||
Erfolgt über zwei yaml files. Zu konfigurieren ist die Verbindung zur Datenbank und die Konfiguration der einzelnen Hotels. In zukunft kommt vermutlich auch noch die Push URL hinzu.
|
||||
|
||||
```yaml
|
||||
database:
|
||||
url: "sqlite+aiosqlite:///alpinebits.db" # For local dev, use SQLite. For prod, override with PostgreSQL URL.
|
||||
# url: "postgresql://user:password@host:port/dbname" # Example for Postgres
|
||||
|
||||
alpine_bits_auth:
|
||||
- hotel_id: "123"
|
||||
hotel_name: "Frangart Inn"
|
||||
username: "alice"
|
||||
password: !secret ALICE_PASSWORD
|
||||
- hotel_id: "456"
|
||||
hotel_name: "Bemelmans"
|
||||
username: "bob"
|
||||
password: !secret BOB_PASSWORD
|
||||
```
|
||||
|
||||
!secret verweist auf einen Eintrag in secrets.yaml. Diese Datei wird aus Sicherheitsgründen nicht auf die Repository hochgeladen. In secrets.yaml können passwörter folgendermaßen angegeben werden
|
||||
|
||||
```yaml
|
||||
ALICE_PASSWORD: "supersecretpassword123"
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
Die Applikation wird in einem Dockercontainer deployed. Um das Container Image zu erstellen ist folgender Befehl notwendig
|
||||
|
||||
```bash
|
||||
uv sync
|
||||
docker build . -t gitea.linter-home.com/jonas/asa_api:master
|
||||
```
|
||||
Dieser Befehl muss im Wurzelverzeichnis der Repository ausgeführt werden. `pwd` sollte irgendwas/alpinebits_python ergeben. Der Punkt hinter dem docker build befehl verweißt nämlich auf das lokale Dockerfile. "-t" steht für tag. In diesem Beispiel wird das Image mit dem Tag `gitea.linter-home.com/jonas/asa_api:master` versehen.
|
||||
|
||||
Ideal wäre eine Build Pipeline in Gitea selbst aber dies aufzusetzen ist etwas schwierig und es ist gut möglich das die Hetzner VM das nicht herhat. Lokal bei mir zuhause ist dies aufgesetzt. War alles andere als leicht.
|
||||
|
||||
Am besten einfach direkt auf dem Zielsystem den Container bauen und im Docker Compose File dann auf dieses Image referenzieren.
|
||||
|
||||
|
||||
### Docker Compose Beispiel mit Traefik Reverse Proxy
|
||||
|
||||
```yaml
|
||||
services:
|
||||
asa_connector:
|
||||
image: gitea.linter-home.com/jonas/asa_api:master
|
||||
container_name: asa_connector
|
||||
restart: unless-stopped
|
||||
|
||||
# Environment variables via .env file
|
||||
env_file:
|
||||
- asa_connector.env
|
||||
|
||||
networks:
|
||||
- external
|
||||
|
||||
# Only expose internally - Traefik will handle external access
|
||||
expose:
|
||||
- "8000"
|
||||
|
||||
user: "1000:1000" # Run as user with UID 1000 and GID 1000
|
||||
|
||||
environment:
|
||||
- ALPINEBITS_CONFIG_DIR=/config
|
||||
|
||||
volumes:
|
||||
- /home/jonas/asa_connector_logs:/app/src/logs
|
||||
- /home/jonas/alpinebits_config:/config
|
||||
|
||||
|
||||
|
||||
# Traefik labels for automatic service discovery
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
# API router - handles /api/* paths on 99tales.net
|
||||
- "traefik.http.routers.asa_connector.rule=Host(`99tales.net`) && PathPrefix(`/api`)"
|
||||
- "traefik.http.routers.asa_connector.entrypoints=https"
|
||||
- "traefik.http.routers.asa_connector.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.services.asa_connector.loadbalancer.server.port=8000"
|
||||
- "traefik.http.routers.asa_connector.priority=100"
|
||||
|
||||
# Redirect middleware for non-API paths
|
||||
- "traefik.http.middlewares.redirect-to-99tales-it.redirectregex.regex=^https://99tales\\.net/(.*)$$"
|
||||
- "traefik.http.middlewares.redirect-to-99tales-it.redirectregex.replacement=https://99tales.it/$${1}"
|
||||
- "traefik.http.middlewares.redirect-to-99tales-it.redirectregex.permanent=true"
|
||||
|
||||
# Catch-all router for non-API paths on 99tales.net (lower priority)
|
||||
- "traefik.http.routers.redirect-router.rule=Host(`99tales.net`)"
|
||||
- "traefik.http.routers.redirect-router.entrypoints=https"
|
||||
- "traefik.http.routers.redirect-router.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.routers.redirect-router.middlewares=redirect-to-99tales-it"
|
||||
- "traefik.http.routers.redirect-router.service=noop@internal"
|
||||
- "traefik.http.routers.redirect-router.priority=1"
|
||||
|
||||
dockerproxy:
|
||||
image: ghcr.io/tecnativa/docker-socket-proxy:latest
|
||||
container_name: dockerproxy
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
CONTAINERS: 1 # read only
|
||||
POST: 0
|
||||
|
||||
networks:
|
||||
- external
|
||||
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
|
||||
traefik:
|
||||
image: traefik:latest
|
||||
container_name: traefik
|
||||
restart: unless-stopped
|
||||
|
||||
|
||||
environment:
|
||||
- DOCKER_HOST=dockerproxy
|
||||
|
||||
networks:
|
||||
- external
|
||||
|
||||
ports:
|
||||
- "80:80" # HTTP
|
||||
- "443:443" # HTTPS
|
||||
- "22:22" # SSH for Gitea
|
||||
|
||||
volumes:
|
||||
- /home/jonas/traefik:/etc/traefik # Traefik configuration files
|
||||
|
||||
|
||||
|
||||
# Health check
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import requests; requests.get('http://localhost:8000/health', timeout=5)"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 60s
|
||||
|
||||
networks: # custom bridge network named 'external'
|
||||
external:
|
||||
name: external
|
||||
driver: bridge
|
||||
```
|
||||
|
||||
Damit das ganze auch funktioniert müssen dns Einträge auf die Virtuelle Machine zeigen in der das ganze läuft. Wurde bei Hostinger für 99tales.net eingerichtet.
|
||||
|
||||
Wie in dem Beispiel ersichtlich wird sowohl ein Log Ordner als auch ein Config ordner in den Container gemapped. Diesen am besten auf dem Host vor Erstellung des Containers erstellen.
|
||||
|
||||
Die Umgebungsvariable `ALPINEBITS_CONFIG_DIR` sagt dann dem Programm wo es die Config finden soll. In dem Ordner kann man die obens erwähnten Konfigurationsdateien speichern. Falls sqlite als Datenbank verwendet wird, findet man dort auch die Datenbank nach erstem ausführen.
|
||||
|
||||
|
||||
|
||||
# TODO Liste
|
||||
|
||||
Need a table in the database that stores requests that have already been acknowledged by the client. Should contain client_id + a list of all acked unique_ids
|
||||
|
||||
|
||||
|
||||
|
||||
Hour alpine bits application needs to mostly act as a server. It needs to provide room reservation information to the ASA alpinebits client at the hotel.
|
||||
|
||||
However in other things we act could potentially act as the client with ASA acting as the alpinebits server. Basically according to the documentation the whole thing depends on who is requesting information and who has it.
|
||||
|
||||
When ASA wants to know our GuestRequests from the Landing page then they are the client and we the server. This causes some problems because our system actually knows less than the hotel system. We can't easiliy add Room Rate information and publish a reservation to ASA because we don't actually know the rooms.
|
||||
|
||||
Just for GuestRequests this should be fine however.
|
||||
|
||||
|
||||
14061
alpinebits.log
Normal file
14061
alpinebits.log
Normal file
File diff suppressed because it is too large
Load Diff
41
config/config.yaml
Normal file
41
config/config.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
# AlpineBits Python config
|
||||
# Use annotatedyaml for secrets and environment-specific overrides
|
||||
|
||||
database:
|
||||
url: "sqlite+aiosqlite:///alpinebits.db" # For local dev, use SQLite. For prod, override with PostgreSQL URL.
|
||||
# url: "postgresql://user:password@host:port/dbname" # Example for Postgres
|
||||
|
||||
# AlpineBits Python config
|
||||
# Use annotatedyaml for secrets and environment-specific overrides
|
||||
|
||||
server:
|
||||
codecontext: "ADVERTISING"
|
||||
code: 70597314
|
||||
companyname: "99tales Gmbh"
|
||||
res_id_source_context: "99tales"
|
||||
|
||||
|
||||
|
||||
logger:
|
||||
level: "INFO" # Set to DEBUG for more verbose output
|
||||
file: "alpinebits.log" # Log file path, or null for console only
|
||||
|
||||
alpine_bits_auth:
|
||||
- hotel_id: "39054_001"
|
||||
hotel_name: "Bemelmans Post"
|
||||
username: "bemelman"
|
||||
password: !secret BEMELMANS_PASSWORD
|
||||
- hotel_id: "135"
|
||||
hotel_name: "Testhotel"
|
||||
username: "sebastian"
|
||||
password: !secret BOB_PASSWORD
|
||||
|
||||
- hotel_id: "39052_001"
|
||||
hotel_name: "Jagthof Kaltern"
|
||||
username: "jagthof"
|
||||
password: !secret JAGTHOF_PASSWORD
|
||||
|
||||
- hotel_id: "39040_001"
|
||||
hotel_name: "Residence Erika"
|
||||
username: "erika"
|
||||
password: !secret ERIKA_PASSWORD
|
||||
13
conftest.py
Normal file
13
conftest.py
Normal file
@@ -0,0 +1,13 @@
|
||||
"""Pytest configuration and path setup for VS Code.
|
||||
|
||||
This configuration file ensures that VS Code can properly discover and run tests
|
||||
by setting up the Python path to include the src directory.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add the src directory to Python path for VS Code test discovery
|
||||
src_path = Path(__file__).parent / "src"
|
||||
if str(src_path) not in sys.path:
|
||||
sys.path.insert(0, str(src_path))
|
||||
1
coverage.json
Normal file
1
coverage.json
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_HotelResNotifRQ xmlns="http://www.opentravel.org/OTA/2003/05" Version="7.000">
|
||||
<HotelReservations>
|
||||
<HotelReservation CreateDateTime="2025-10-07T15:13:38.831800+00:00" ResStatus="Requested" RoomStayReservation="true">
|
||||
<UniqueID Type="14" ID="8e68dab6-7c2e-4c67-9471-b8cbfb7b"/>
|
||||
<RoomStays>
|
||||
<RoomStay>
|
||||
<GuestCounts>
|
||||
<GuestCount Count="13"/>
|
||||
</GuestCounts>
|
||||
<TimeSpan Start="2025-10-25" End="2025-10-26"/>
|
||||
</RoomStay>
|
||||
</RoomStays>
|
||||
<ResGuests>
|
||||
<ResGuest>
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile>
|
||||
<Customer Language="de">
|
||||
<PersonName>
|
||||
<NamePrefix>Frau</NamePrefix>
|
||||
<GivenName>Christine</GivenName>
|
||||
<Surname>Niederkofler</Surname>
|
||||
</PersonName>
|
||||
<Telephone PhoneTechType="5" PhoneNumber="+4953346312"/>
|
||||
<Email Remark="newsletter:yes">info@ledermode.at</Email>
|
||||
</Customer>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
</Profiles>
|
||||
</ResGuest>
|
||||
</ResGuests>
|
||||
<ResGlobalInfo>
|
||||
<Comments>
|
||||
<Comment Name="additional info">
|
||||
<Text>Angebot/Offerta: Törggelewochen - Herbstliche Genüsse & Südtiroler Tradition</Text>
|
||||
</Comment>
|
||||
<Comment Name="customer comment">
|
||||
<Text>Hallo. Wir würden gerne mit unseren Mitarbeitern vom 25.10 - 26.10.25 nach Südtirol fahren.
|
||||
Geplant wäre am Samstagabend Törggelen und am Sonntag nach dem Frühstück mit der Gondel zur Seiser Alm zu fahren.
|
||||
Wir sind ca. 13 Personen (es können gerne auch 3-Bettzimmer dabei sein falls vorhanden. Sonst DZ und wir benötigen 1 EZ).
|
||||
Bitte um ein Angebot für Törggelen, Übernachtung und Frühstück. Vielen lieben Dank! Christine Niederkofler</Text>
|
||||
</Comment>
|
||||
</Comments>
|
||||
<HotelReservationIDs>
|
||||
<HotelReservationID ResID_Type="13" ResID_Value="Cj0KCQjw3OjGBhDYARIsADd-uX65gXKdbOti_3OOA50T-B9Uj-zsOzXJ7g2-8Tz_" ResID_Source="google" ResID_SourceContext="99tales"/>
|
||||
</HotelReservationIDs>
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile ProfileType="4">
|
||||
<CompanyInfo>
|
||||
<CompanyName Code="who knows?" CodeContext="who knows?">99tales GmbH</CompanyName>
|
||||
</CompanyInfo>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
</Profiles>
|
||||
<BasicPropertyInfo HotelCode="12345" HotelName="Frangart Inn"/>
|
||||
</ResGlobalInfo>
|
||||
</HotelReservation>
|
||||
</HotelReservations>
|
||||
</OTA_HotelResNotifRQ>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_HotelResNotifRQ xmlns="http://www.opentravel.org/OTA/2003/05" Version="7.000">
|
||||
<HotelReservations/>
|
||||
</OTA_HotelResNotifRQ>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_HotelResNotifRQ xmlns="http://www.opentravel.org/OTA/2003/05" Version="7.000">
|
||||
<HotelReservations>
|
||||
<HotelReservation CreateDateTime="2025-10-07T14:05:37.563674+00:00" ResStatus="Requested" RoomStayReservation="true">
|
||||
<UniqueID Type="14" ID="c52702c9-55b9-44e1-b158-ec9544c7"/>
|
||||
<RoomStays>
|
||||
<RoomStay>
|
||||
<GuestCounts>
|
||||
<GuestCount Count="3"/>
|
||||
<GuestCount Count="1" Age="12"/>
|
||||
</GuestCounts>
|
||||
<TimeSpan Start="2026-01-02" End="2026-01-07"/>
|
||||
</RoomStay>
|
||||
</RoomStays>
|
||||
<ResGuests>
|
||||
<ResGuest>
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile>
|
||||
<Customer Language="it">
|
||||
<PersonName>
|
||||
<NamePrefix>Frau</NamePrefix>
|
||||
<GivenName>Genesia</GivenName>
|
||||
<Surname>Supino</Surname>
|
||||
</PersonName>
|
||||
<Telephone PhoneTechType="5" PhoneNumber="+393406259979"/>
|
||||
<Email Remark="newsletter:yes">supinogenesia@gmail.com</Email>
|
||||
</Customer>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
</Profiles>
|
||||
</ResGuest>
|
||||
</ResGuests>
|
||||
<ResGlobalInfo>
|
||||
<HotelReservationIDs>
|
||||
<HotelReservationID ResID_Type="13" ResID_Value="IwZXh0bgNhZW0BMABhZGlkAassWPh1b8QBHoRc2S24gMktdNKiPwEvGYMK3rB-mn" ResID_Source="Facebook_Mobile_Feed" ResID_SourceContext="99tales"/>
|
||||
</HotelReservationIDs>
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile ProfileType="4">
|
||||
<CompanyInfo>
|
||||
<CompanyName Code="who knows?" CodeContext="who knows?">99tales GmbH</CompanyName>
|
||||
</CompanyInfo>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
</Profiles>
|
||||
<BasicPropertyInfo HotelCode="12345" HotelName="Bemelmans Post"/>
|
||||
</ResGlobalInfo>
|
||||
</HotelReservation>
|
||||
</HotelReservations>
|
||||
</OTA_HotelResNotifRQ>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_HotelResNotifRQ xmlns="http://www.opentravel.org/OTA/2003/05" Version="7.000">
|
||||
<HotelReservations>
|
||||
<HotelReservation CreateDateTime="2025-10-07T14:24:04.943026+00:00" ResStatus="Requested" RoomStayReservation="true">
|
||||
<UniqueID Type="14" ID="c52702c9-55b9-44e1-b158-ec9544c7"/>
|
||||
<RoomStays>
|
||||
<RoomStay>
|
||||
<GuestCounts>
|
||||
<GuestCount Count="3"/>
|
||||
<GuestCount Count="1" Age="12"/>
|
||||
</GuestCounts>
|
||||
<TimeSpan Start="2026-01-02" End="2026-01-07"/>
|
||||
</RoomStay>
|
||||
</RoomStays>
|
||||
<ResGuests>
|
||||
<ResGuest>
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile>
|
||||
<Customer Language="it">
|
||||
<PersonName>
|
||||
<NamePrefix>Frau</NamePrefix>
|
||||
<GivenName>Genesia</GivenName>
|
||||
<Surname>Supino</Surname>
|
||||
</PersonName>
|
||||
<Telephone PhoneTechType="5" PhoneNumber="+393406259979"/>
|
||||
<Email Remark="newsletter:yes">supinogenesia@gmail.com</Email>
|
||||
</Customer>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
</Profiles>
|
||||
</ResGuest>
|
||||
</ResGuests>
|
||||
<ResGlobalInfo>
|
||||
<HotelReservationIDs>
|
||||
<HotelReservationID ResID_Type="13" ResID_Value="IwZXh0bgNhZW0BMABhZGlkAassWPh1b8QBHoRc2S24gMktdNKiPwEvGYMK3rB-mn" ResID_Source="Facebook_Mobile_Feed" ResID_SourceContext="99tales"/>
|
||||
</HotelReservationIDs>
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile ProfileType="4">
|
||||
<CompanyInfo>
|
||||
<CompanyName Code="who knows?" CodeContext="who knows?">99tales GmbH</CompanyName>
|
||||
</CompanyInfo>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
</Profiles>
|
||||
<BasicPropertyInfo HotelCode="12345" HotelName="Bemelmans Post"/>
|
||||
</ResGlobalInfo>
|
||||
</HotelReservation>
|
||||
</HotelReservations>
|
||||
</OTA_HotelResNotifRQ>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_HotelResNotifRQ xmlns="http://www.opentravel.org/OTA/2003/05" Version="7.000">
|
||||
<HotelReservations>
|
||||
<HotelReservation CreateDateTime="2025-10-07T14:32:52.523968+00:00" ResStatus="Requested" RoomStayReservation="true">
|
||||
<UniqueID Type="14" ID="c52702c9-55b9-44e1-b158-ec9544c7"/>
|
||||
<RoomStays>
|
||||
<RoomStay>
|
||||
<GuestCounts>
|
||||
<GuestCount Count="3"/>
|
||||
<GuestCount Count="1" Age="12"/>
|
||||
</GuestCounts>
|
||||
<TimeSpan Start="2026-01-02" End="2026-01-07"/>
|
||||
</RoomStay>
|
||||
</RoomStays>
|
||||
<ResGuests>
|
||||
<ResGuest>
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile>
|
||||
<Customer Language="it">
|
||||
<PersonName>
|
||||
<NamePrefix>Frau</NamePrefix>
|
||||
<GivenName>Genesia</GivenName>
|
||||
<Surname>Supino</Surname>
|
||||
</PersonName>
|
||||
<Telephone PhoneTechType="5" PhoneNumber="+393406259979"/>
|
||||
<Email Remark="newsletter:yes">supinogenesia@gmail.com</Email>
|
||||
</Customer>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
</Profiles>
|
||||
</ResGuest>
|
||||
</ResGuests>
|
||||
<ResGlobalInfo>
|
||||
<HotelReservationIDs>
|
||||
<HotelReservationID ResID_Type="13" ResID_Value="IwZXh0bgNhZW0BMABhZGlkAassWPh1b8QBHoRc2S24gMktdNKiPwEvGYMK3rB-mn" ResID_Source="Facebook_Mobile_Feed" ResID_SourceContext="99tales"/>
|
||||
</HotelReservationIDs>
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile ProfileType="4">
|
||||
<CompanyInfo>
|
||||
<CompanyName Code="who knows?" CodeContext="who knows?">99tales GmbH</CompanyName>
|
||||
</CompanyInfo>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
</Profiles>
|
||||
<BasicPropertyInfo HotelCode="12345" HotelName="Bemelmans Post"/>
|
||||
</ResGlobalInfo>
|
||||
</HotelReservation>
|
||||
</HotelReservations>
|
||||
</OTA_HotelResNotifRQ>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_HotelResNotifRQ xmlns="http://www.opentravel.org/OTA/2003/05" Version="7.000">
|
||||
<HotelReservations>
|
||||
<HotelReservation CreateDateTime="2025-10-07T15:12:25.274095+00:00" ResStatus="Requested" RoomStayReservation="true">
|
||||
<UniqueID Type="14" ID="c52702c9-55b9-44e1-b158-ec9544c7"/>
|
||||
<RoomStays>
|
||||
<RoomStay>
|
||||
<GuestCounts>
|
||||
<GuestCount Count="3"/>
|
||||
<GuestCount Count="1" Age="12"/>
|
||||
</GuestCounts>
|
||||
<TimeSpan Start="2026-01-02" End="2026-01-07"/>
|
||||
</RoomStay>
|
||||
</RoomStays>
|
||||
<ResGuests>
|
||||
<ResGuest>
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile>
|
||||
<Customer Language="it">
|
||||
<PersonName>
|
||||
<NamePrefix>Frau</NamePrefix>
|
||||
<GivenName>Genesia</GivenName>
|
||||
<Surname>Supino</Surname>
|
||||
</PersonName>
|
||||
<Telephone PhoneTechType="5" PhoneNumber="+393406259979"/>
|
||||
<Email Remark="newsletter:yes">supinogenesia@gmail.com</Email>
|
||||
</Customer>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
</Profiles>
|
||||
</ResGuest>
|
||||
</ResGuests>
|
||||
<ResGlobalInfo>
|
||||
<HotelReservationIDs>
|
||||
<HotelReservationID ResID_Type="13" ResID_Value="IwZXh0bgNhZW0BMABhZGlkAassWPh1b8QBHoRc2S24gMktdNKiPwEvGYMK3rB-mn" ResID_Source="Facebook_Mobile_Feed" ResID_SourceContext="99tales"/>
|
||||
</HotelReservationIDs>
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile ProfileType="4">
|
||||
<CompanyInfo>
|
||||
<CompanyName Code="who knows?" CodeContext="who knows?">99tales GmbH</CompanyName>
|
||||
</CompanyInfo>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
</Profiles>
|
||||
<BasicPropertyInfo HotelCode="12345" HotelName="Bemelmans Post"/>
|
||||
</ResGlobalInfo>
|
||||
</HotelReservation>
|
||||
</HotelReservations>
|
||||
</OTA_HotelResNotifRQ>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_HotelResNotifRQ xmlns="http://www.opentravel.org/OTA/2003/05" Version="7.000">
|
||||
<HotelReservations>
|
||||
<HotelReservation CreateDateTime="2025-10-07T09:38:38.167778+00:00" ResStatus="Requested" RoomStayReservation="true">
|
||||
<UniqueID Type="14" ID="c52702c9-55b9-44e1-b158-ec9544c7"/>
|
||||
<RoomStays>
|
||||
<RoomStay>
|
||||
<GuestCounts>
|
||||
<GuestCount Count="3"/>
|
||||
<GuestCount Count="1" Age="12"/>
|
||||
</GuestCounts>
|
||||
<TimeSpan Start="2026-01-02" End="2026-01-07"/>
|
||||
</RoomStay>
|
||||
</RoomStays>
|
||||
<ResGuests>
|
||||
<ResGuest>
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile>
|
||||
<Customer Language="it">
|
||||
<PersonName>
|
||||
<NamePrefix>Frau</NamePrefix>
|
||||
<GivenName>Genesia</GivenName>
|
||||
<Surname>Supino</Surname>
|
||||
</PersonName>
|
||||
<Telephone PhoneTechType="5" PhoneNumber="+393406259979"/>
|
||||
<Email Remark="newsletter:yes">supinogenesia@gmail.com</Email>
|
||||
</Customer>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
</Profiles>
|
||||
</ResGuest>
|
||||
</ResGuests>
|
||||
<ResGlobalInfo>
|
||||
<HotelReservationIDs>
|
||||
<HotelReservationID ResID_Type="13" ResID_Value="IwZXh0bgNhZW0BMABhZGlkAassWPh1b8QBHoRc2S24gMktdNKiPwEvGYMK3rB-mn" ResID_Source="Facebook_Mobile_Feed" ResID_SourceContext="99tales"/>
|
||||
</HotelReservationIDs>
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile ProfileType="4">
|
||||
<CompanyInfo>
|
||||
<CompanyName Code="who knows?" CodeContext="who knows?">99tales GmbH</CompanyName>
|
||||
</CompanyInfo>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
</Profiles>
|
||||
<BasicPropertyInfo HotelCode="12345" HotelName="Bemelmans Post"/>
|
||||
</ResGlobalInfo>
|
||||
</HotelReservation>
|
||||
</HotelReservations>
|
||||
</OTA_HotelResNotifRQ>
|
||||
250
logs/wix_test_data_20250929_154411.json
Normal file
250
logs/wix_test_data_20250929_154411.json
Normal file
@@ -0,0 +1,250 @@
|
||||
{
|
||||
"timestamp": "2025-09-29T15:44:11.839852",
|
||||
"client_ip": "127.0.0.1",
|
||||
"headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "6920"
|
||||
},
|
||||
"data": {
|
||||
"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Angebot auswählen",
|
||||
"value": "Herbstferien - Familienzeit mit Dolomitenblick"
|
||||
},
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2025-10-31"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2025-11-02"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "3"
|
||||
},
|
||||
{
|
||||
"label": "Alter Kind 1",
|
||||
"value": "3"
|
||||
},
|
||||
{
|
||||
"label": "Alter Kind 2",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"label": "Alter Kind 3",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Frau"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Elena"
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Battiloro"
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "e.battiloro1@gmail.com"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+39 333 767 3262"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Non selezionato"
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": "ig"
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": "Instagram_Stories"
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": "Conversions_Hotel_Bemelmans_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": "Cold_Traffic_Conversions_Hotel_Bemelmans_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": "Grafik_4_Spätsommer_23.08-07.09_Landingpage_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": "120232007764490196"
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": "120232007764490196"
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": "PAZXh0bgNhZW0BMABhZGlkAasmYBhk4DQBp02L46Rl1jAuccxsOaeFSv7WSFnP-MQCsOrz9yDnKRH4hwZ7GEgxF9gy0_OF_aem_qSvrs6xsBkvTaI_Y9_hfnQ"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2025-11-02",
|
||||
"field:number_7cf5": "2",
|
||||
"field:utm_source": "ig",
|
||||
"submissionTime": "2025-09-28T13:26:07.938Z",
|
||||
"field:alter_kind_3": "3",
|
||||
"field:gad_source": "",
|
||||
"field:form_field_5a7b": "Non selezionato",
|
||||
"field:gad_campaignid": "",
|
||||
"field:utm_medium": "Instagram_Stories",
|
||||
"field:utm_term_id": "120232007764490196",
|
||||
"context": {
|
||||
"metaSiteId": "1dea821c-8168-4736-96e4-4b92e8b364cf",
|
||||
"activationId": "3fd865e1-f44a-49d2-ae29-19cf77ee488a"
|
||||
},
|
||||
"field:email_5139": "e.battiloro1@gmail.com",
|
||||
"field:phone_4c77": "+39 333 767 3262",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "3fd865e1-f44a-49d2-ae29-19cf77ee488a"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "a976f18c-fa86-495d-be1e-676df188eeae"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "152db4d7-5263-40c4-be2b-1c81476318b7"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "",
|
||||
"formFieldMask": [
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"metaSiteId"
|
||||
],
|
||||
"field:alter_kind_4": "0",
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Elena",
|
||||
"last": "Battiloro"
|
||||
},
|
||||
"email": "e.battiloro1@gmail.com",
|
||||
"locale": "it-it",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+39 333 767 3262",
|
||||
"id": "7e5c8512-b88e-4cf0-8d0c-9ebe6b210924",
|
||||
"countryCode": "IT",
|
||||
"e164Phone": "+393337673262",
|
||||
"primary": true,
|
||||
"phone": "333 767 3262"
|
||||
}
|
||||
],
|
||||
"contactId": "b9d47825-9f84-4ae7-873c-d169851b5888",
|
||||
"emails": [
|
||||
{
|
||||
"id": "c5609c67-5eba-4068-ab21-8a2ab9a09a27",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "e.battiloro1@gmail.com",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-09-28T13:26:09.916Z",
|
||||
"phone": "+393337673262",
|
||||
"createdDate": "2025-08-08T13:05:23.733Z"
|
||||
},
|
||||
"submissionId": "02fbc71c-745b-4c73-9cba-827d0958117a",
|
||||
"field:anzahl_kinder": "3",
|
||||
"field:alter_kind_25": "1",
|
||||
"field:first_name_abae": "Elena",
|
||||
"field:utm_content_id": "120232007764490196",
|
||||
"field:utm_campaign": "Conversions_Hotel_Bemelmans_ITA",
|
||||
"field:utm_term": "Cold_Traffic_Conversions_Hotel_Bemelmans_ITA",
|
||||
"contactId": "b9d47825-9f84-4ae7-873c-d169851b5888",
|
||||
"field:date_picker_a7c8": "2025-10-31",
|
||||
"field:angebot_auswaehlen": "Herbstferien - Familienzeit mit Dolomitenblick",
|
||||
"field:utm_content": "Grafik_4_Spätsommer_23.08-07.09_Landingpage_ITA",
|
||||
"field:last_name_d97c": "Battiloro",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/1dea821c-8168-4736-96e4-4b92e8b364cf/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F1dea821c-8168-4736-96e4-4b92e8b364cf%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:gbraid": "",
|
||||
"field:fbclid": "PAZXh0bgNhZW0BMABhZGlkAasmYBhk4DQBp02L46Rl1jAuccxsOaeFSv7WSFnP-MQCsOrz9yDnKRH4hwZ7GEgxF9gy0_OF_aem_qSvrs6xsBkvTaI_Y9_hfnQ",
|
||||
"field:anrede": "Frau",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}
|
||||
},
|
||||
"origin_header": null,
|
||||
"all_headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "6920"
|
||||
}
|
||||
}
|
||||
250
logs/wix_test_data_20250929_154454.json
Normal file
250
logs/wix_test_data_20250929_154454.json
Normal file
@@ -0,0 +1,250 @@
|
||||
{
|
||||
"timestamp": "2025-09-29T15:44:54.746579",
|
||||
"client_ip": "127.0.0.1",
|
||||
"headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "6920"
|
||||
},
|
||||
"data": {
|
||||
"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Angebot auswählen",
|
||||
"value": "Herbstferien - Familienzeit mit Dolomitenblick"
|
||||
},
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2025-10-31"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2025-11-02"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "3"
|
||||
},
|
||||
{
|
||||
"label": "Alter Kind 1",
|
||||
"value": "3"
|
||||
},
|
||||
{
|
||||
"label": "Alter Kind 2",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"label": "Alter Kind 3",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Frau"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Elena"
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Battiloro"
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "e.battiloro1@gmail.com"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+39 333 767 3262"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Non selezionato"
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": "ig"
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": "Instagram_Stories"
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": "Conversions_Hotel_Bemelmans_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": "Cold_Traffic_Conversions_Hotel_Bemelmans_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": "Grafik_4_Spätsommer_23.08-07.09_Landingpage_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": "120232007764490196"
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": "120232007764490196"
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": "PAZXh0bgNhZW0BMABhZGlkAasmYBhk4DQBp02L46Rl1jAuccxsOaeFSv7WSFnP-MQCsOrz9yDnKRH4hwZ7GEgxF9gy0_OF_aem_qSvrs6xsBkvTaI_Y9_hfnQ"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2025-11-02",
|
||||
"field:number_7cf5": "2",
|
||||
"field:utm_source": "ig",
|
||||
"submissionTime": "2025-09-28T13:26:07.938Z",
|
||||
"field:alter_kind_3": "3",
|
||||
"field:gad_source": "",
|
||||
"field:form_field_5a7b": "Non selezionato",
|
||||
"field:gad_campaignid": "",
|
||||
"field:utm_medium": "Instagram_Stories",
|
||||
"field:utm_term_id": "120232007764490196",
|
||||
"context": {
|
||||
"metaSiteId": "1dea821c-8168-4736-96e4-4b92e8b364cf",
|
||||
"activationId": "3fd865e1-f44a-49d2-ae29-19cf77ee488a"
|
||||
},
|
||||
"field:email_5139": "e.battiloro1@gmail.com",
|
||||
"field:phone_4c77": "+39 333 767 3262",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "3fd865e1-f44a-49d2-ae29-19cf77ee488a"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "a976f18c-fa86-495d-be1e-676df188eeae"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "152db4d7-5263-40c4-be2b-1c81476318b7"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "",
|
||||
"formFieldMask": [
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"metaSiteId"
|
||||
],
|
||||
"field:alter_kind_4": "0",
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Elena",
|
||||
"last": "Battiloro"
|
||||
},
|
||||
"email": "e.battiloro1@gmail.com",
|
||||
"locale": "it-it",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+39 333 767 3262",
|
||||
"id": "7e5c8512-b88e-4cf0-8d0c-9ebe6b210924",
|
||||
"countryCode": "IT",
|
||||
"e164Phone": "+393337673262",
|
||||
"primary": true,
|
||||
"phone": "333 767 3262"
|
||||
}
|
||||
],
|
||||
"contactId": "b9d47825-9f84-4ae7-873c-d169851b5888",
|
||||
"emails": [
|
||||
{
|
||||
"id": "c5609c67-5eba-4068-ab21-8a2ab9a09a27",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "e.battiloro1@gmail.com",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-09-28T13:26:09.916Z",
|
||||
"phone": "+393337673262",
|
||||
"createdDate": "2025-08-08T13:05:23.733Z"
|
||||
},
|
||||
"submissionId": "02fbc71c-745b-4c73-9cba-827d0958117a",
|
||||
"field:anzahl_kinder": "3",
|
||||
"field:alter_kind_25": "1",
|
||||
"field:first_name_abae": "Elena",
|
||||
"field:utm_content_id": "120232007764490196",
|
||||
"field:utm_campaign": "Conversions_Hotel_Bemelmans_ITA",
|
||||
"field:utm_term": "Cold_Traffic_Conversions_Hotel_Bemelmans_ITA",
|
||||
"contactId": "b9d47825-9f84-4ae7-873c-d169851b5888",
|
||||
"field:date_picker_a7c8": "2025-10-31",
|
||||
"field:angebot_auswaehlen": "Herbstferien - Familienzeit mit Dolomitenblick",
|
||||
"field:utm_content": "Grafik_4_Spätsommer_23.08-07.09_Landingpage_ITA",
|
||||
"field:last_name_d97c": "Battiloro",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/1dea821c-8168-4736-96e4-4b92e8b364cf/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F1dea821c-8168-4736-96e4-4b92e8b364cf%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:gbraid": "",
|
||||
"field:fbclid": "PAZXh0bgNhZW0BMABhZGlkAasmYBhk4DQBp02L46Rl1jAuccxsOaeFSv7WSFnP-MQCsOrz9yDnKRH4hwZ7GEgxF9gy0_OF_aem_qSvrs6xsBkvTaI_Y9_hfnQ",
|
||||
"field:anrede": "Frau",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}
|
||||
},
|
||||
"origin_header": null,
|
||||
"all_headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "6920"
|
||||
}
|
||||
}
|
||||
170
logs/wix_test_data_20250929_160843.json
Normal file
170
logs/wix_test_data_20250929_160843.json
Normal file
@@ -0,0 +1,170 @@
|
||||
{
|
||||
"timestamp": "2025-09-29T16:08:43.177480",
|
||||
"client_ip": "127.0.0.1",
|
||||
"headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "4518"
|
||||
},
|
||||
"data": {
|
||||
"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2026-01-17"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2026-01-24"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Herr"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Weislinger "
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Alain "
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "alain-et-evelyne@hotmail.fr"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+33 6 41 77 99 09"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Cochée"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2026-01-24",
|
||||
"field:number_7cf5": "2",
|
||||
"submissionTime": "2025-09-27T19:36:39.137Z",
|
||||
"field:form_field_5a7b": "Cochée",
|
||||
"context": {
|
||||
"metaSiteId": "7b28c2ce-1e20-4d07-9e86-73d822007e18",
|
||||
"activationId": "d59c463c-96e0-4742-b4f7-70b8f0431168"
|
||||
},
|
||||
"field:email_5139": "alain-et-evelyne@hotmail.fr",
|
||||
"field:phone_4c77": "+33 6 41 77 99 09",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "d59c463c-96e0-4742-b4f7-70b8f0431168"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "483806f6-24ba-413f-9431-6b1ad9379f5c"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "a85d9873-f8ed-426a-90b0-fb64a8e50406"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"formFieldMask": [
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Weislinger",
|
||||
"last": "Alain"
|
||||
},
|
||||
"email": "alain-et-evelyne@hotmail.fr",
|
||||
"locale": "de-de",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+33 6 41 77 99 09",
|
||||
"id": "90ffc824-1fd7-4167-b29f-24a4b62a0773",
|
||||
"countryCode": "FR",
|
||||
"e164Phone": "+33641779909",
|
||||
"primary": true,
|
||||
"phone": "6 41 77 99 09"
|
||||
}
|
||||
],
|
||||
"contactId": "250e24db-d41e-4f6e-835d-75acdf2ef2b7",
|
||||
"emails": [
|
||||
{
|
||||
"id": "2c071108-2410-4db8-99fa-b50b75a02493",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "alain-et-evelyne@hotmail.fr",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-09-27T19:36:41.908Z",
|
||||
"phone": "+33641779909",
|
||||
"createdDate": "2025-09-27T19:36:41.054Z"
|
||||
},
|
||||
"submissionId": "6cfee967-69a8-454a-a10e-0aa03868ba6d",
|
||||
"field:anzahl_kinder": "0",
|
||||
"field:first_name_abae": "Weislinger ",
|
||||
"contactId": "250e24db-d41e-4f6e-835d-75acdf2ef2b7",
|
||||
"field:date_picker_a7c8": "2026-01-17",
|
||||
"field:last_name_d97c": "Alain ",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/7b28c2ce-1e20-4d07-9e86-73d822007e18/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F7b28c2ce-1e20-4d07-9e86-73d822007e18%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:anrede": "Herr",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}
|
||||
},
|
||||
"origin_header": null,
|
||||
"all_headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "4518"
|
||||
}
|
||||
}
|
||||
170
logs/wix_test_data_20250929_162447.json
Normal file
170
logs/wix_test_data_20250929_162447.json
Normal file
@@ -0,0 +1,170 @@
|
||||
{
|
||||
"timestamp": "2025-09-29T16:24:47.833595",
|
||||
"client_ip": "127.0.0.1",
|
||||
"headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "4518"
|
||||
},
|
||||
"data": {
|
||||
"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2026-01-17"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2026-01-24"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Herr"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Weislinger "
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Alain "
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "alain-et-evelyne@hotmail.fr"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+33 6 41 77 99 09"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Cochée"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2026-01-24",
|
||||
"field:number_7cf5": "2",
|
||||
"submissionTime": "2025-09-27T19:36:39.137Z",
|
||||
"field:form_field_5a7b": "Cochée",
|
||||
"context": {
|
||||
"metaSiteId": "7b28c2ce-1e20-4d07-9e86-73d822007e18",
|
||||
"activationId": "d59c463c-96e0-4742-b4f7-70b8f0431168"
|
||||
},
|
||||
"field:email_5139": "alain-et-evelyne@hotmail.fr",
|
||||
"field:phone_4c77": "+33 6 41 77 99 09",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "d59c463c-96e0-4742-b4f7-70b8f0431168"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "483806f6-24ba-413f-9431-6b1ad9379f5c"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "a85d9873-f8ed-426a-90b0-fb64a8e50406"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"formFieldMask": [
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Weislinger",
|
||||
"last": "Alain"
|
||||
},
|
||||
"email": "alain-et-evelyne@hotmail.fr",
|
||||
"locale": "de-de",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+33 6 41 77 99 09",
|
||||
"id": "90ffc824-1fd7-4167-b29f-24a4b62a0773",
|
||||
"countryCode": "FR",
|
||||
"e164Phone": "+33641779909",
|
||||
"primary": true,
|
||||
"phone": "6 41 77 99 09"
|
||||
}
|
||||
],
|
||||
"contactId": "250e24db-d41e-4f6e-835d-75acdf2ef2b7",
|
||||
"emails": [
|
||||
{
|
||||
"id": "2c071108-2410-4db8-99fa-b50b75a02493",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "alain-et-evelyne@hotmail.fr",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-09-27T19:36:41.908Z",
|
||||
"phone": "+33641779909",
|
||||
"createdDate": "2025-09-27T19:36:41.054Z"
|
||||
},
|
||||
"submissionId": "6cfee967-69a8-454a-a10e-0aa03868ba6d",
|
||||
"field:anzahl_kinder": "0",
|
||||
"field:first_name_abae": "Weislinger ",
|
||||
"contactId": "250e24db-d41e-4f6e-835d-75acdf2ef2b7",
|
||||
"field:date_picker_a7c8": "2026-01-17",
|
||||
"field:last_name_d97c": "Alain ",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/7b28c2ce-1e20-4d07-9e86-73d822007e18/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F7b28c2ce-1e20-4d07-9e86-73d822007e18%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:anrede": "Herr",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}
|
||||
},
|
||||
"origin_header": null,
|
||||
"all_headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "4518"
|
||||
}
|
||||
}
|
||||
170
logs/wix_test_data_20250929_163212.json
Normal file
170
logs/wix_test_data_20250929_163212.json
Normal file
@@ -0,0 +1,170 @@
|
||||
{
|
||||
"timestamp": "2025-09-29T16:32:12.776585",
|
||||
"client_ip": "127.0.0.1",
|
||||
"headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "4518"
|
||||
},
|
||||
"data": {
|
||||
"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2026-01-17"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2026-01-24"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Herr"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Weislinger "
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Alain "
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "alain-et-evelyne@hotmail.fr"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+33 6 41 77 99 09"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Cochée"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2026-01-24",
|
||||
"field:number_7cf5": "2",
|
||||
"submissionTime": "2025-09-27T19:36:39.137Z",
|
||||
"field:form_field_5a7b": "Cochée",
|
||||
"context": {
|
||||
"metaSiteId": "7b28c2ce-1e20-4d07-9e86-73d822007e18",
|
||||
"activationId": "d59c463c-96e0-4742-b4f7-70b8f0431168"
|
||||
},
|
||||
"field:email_5139": "alain-et-evelyne@hotmail.fr",
|
||||
"field:phone_4c77": "+33 6 41 77 99 09",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "d59c463c-96e0-4742-b4f7-70b8f0431168"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "483806f6-24ba-413f-9431-6b1ad9379f5c"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "a85d9873-f8ed-426a-90b0-fb64a8e50406"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"formFieldMask": [
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Weislinger",
|
||||
"last": "Alain"
|
||||
},
|
||||
"email": "alain-et-evelyne@hotmail.fr",
|
||||
"locale": "de-de",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+33 6 41 77 99 09",
|
||||
"id": "90ffc824-1fd7-4167-b29f-24a4b62a0773",
|
||||
"countryCode": "FR",
|
||||
"e164Phone": "+33641779909",
|
||||
"primary": true,
|
||||
"phone": "6 41 77 99 09"
|
||||
}
|
||||
],
|
||||
"contactId": "250e24db-d41e-4f6e-835d-75acdf2ef2b7",
|
||||
"emails": [
|
||||
{
|
||||
"id": "2c071108-2410-4db8-99fa-b50b75a02493",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "alain-et-evelyne@hotmail.fr",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-09-27T19:36:41.908Z",
|
||||
"phone": "+33641779909",
|
||||
"createdDate": "2025-09-27T19:36:41.054Z"
|
||||
},
|
||||
"submissionId": "6cfee967-69a8-454a-a10e-0aa03868ba6d",
|
||||
"field:anzahl_kinder": "0",
|
||||
"field:first_name_abae": "Weislinger ",
|
||||
"contactId": "250e24db-d41e-4f6e-835d-75acdf2ef2b7",
|
||||
"field:date_picker_a7c8": "2026-01-17",
|
||||
"field:last_name_d97c": "Alain ",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/7b28c2ce-1e20-4d07-9e86-73d822007e18/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F7b28c2ce-1e20-4d07-9e86-73d822007e18%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:anrede": "Herr",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}
|
||||
},
|
||||
"origin_header": null,
|
||||
"all_headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "4518"
|
||||
}
|
||||
}
|
||||
240
logs/wix_test_data_20250929_163449.json
Normal file
240
logs/wix_test_data_20250929_163449.json
Normal file
@@ -0,0 +1,240 @@
|
||||
{
|
||||
"timestamp": "2025-09-29T16:34:49.785457",
|
||||
"client_ip": "127.0.0.1",
|
||||
"headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "6638"
|
||||
},
|
||||
"data": {
|
||||
"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Angebot auswählen",
|
||||
"value": "Zimmer: Doppelzimmer"
|
||||
},
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2025-10-03"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2025-10-05"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"label": "Alter Kind 1",
|
||||
"value": "3"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Familie"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Miriana"
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Darman"
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "miriana.m9@gmail.com"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+39 348 443 0969"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Non selezionato"
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": "ig"
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": "Instagram_Stories"
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": "Conversions_Hotel_Bemelmans_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": "Cold_Traffic_Conversions_Hotel_Bemelmans_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": "Grafik_4_Spätsommer_23.08-07.09_Landingpage_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": "120232007764490196"
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": "120232007764490196"
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": "PAZXh0bgNhZW0BMABhZGlkAasmYBTNE3QBp1jWuJ9zIpfEGRJMP63fMAMI405yvG5EtH-OT0PxSkAbBJaudFHR6cMtkdHu_aem_fopaFtECyVPNW9fmWfEkyA"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2025-10-05",
|
||||
"field:number_7cf5": "2",
|
||||
"field:utm_source": "ig",
|
||||
"submissionTime": "2025-09-27T07:04:55.843Z",
|
||||
"field:alter_kind_3": "3",
|
||||
"field:gad_source": "",
|
||||
"field:form_field_5a7b": "Non selezionato",
|
||||
"field:gad_campaignid": "",
|
||||
"field:utm_medium": "Instagram_Stories",
|
||||
"field:utm_term_id": "120232007764490196",
|
||||
"context": {
|
||||
"metaSiteId": "1dea821c-8168-4736-96e4-4b92e8b364cf",
|
||||
"activationId": "d41b7796-dca2-40f1-8245-c2f26a096f19"
|
||||
},
|
||||
"field:email_5139": "miriana.m9@gmail.com",
|
||||
"field:phone_4c77": "+39 348 443 0969",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "d41b7796-dca2-40f1-8245-c2f26a096f19"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "a976f18c-fa86-495d-be1e-676df188eeae"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "152db4d7-5263-40c4-be2b-1c81476318b7"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "",
|
||||
"formFieldMask": [
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Miriana",
|
||||
"last": "Darman"
|
||||
},
|
||||
"email": "miriana.m9@gmail.com",
|
||||
"locale": "it-it",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+39 348 443 0969",
|
||||
"id": "ac9d623e-6aaa-4022-856a-0dd64d0ff3fb",
|
||||
"countryCode": "IT",
|
||||
"e164Phone": "+393484430969",
|
||||
"primary": true,
|
||||
"phone": "348 443 0969"
|
||||
}
|
||||
],
|
||||
"contactId": "bcc29403-82ac-445a-be52-90a67180f16f",
|
||||
"emails": [
|
||||
{
|
||||
"id": "448de804-7353-46ed-9ae3-9c13ca521917",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "miriana.m9@gmail.com",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-09-27T07:04:58.724Z",
|
||||
"phone": "+393484430969",
|
||||
"createdDate": "2025-09-27T07:04:57.752Z"
|
||||
},
|
||||
"submissionId": "3150614e-1b0a-47ba-a774-b0a0c71d8110",
|
||||
"field:anzahl_kinder": "1",
|
||||
"field:first_name_abae": "Miriana",
|
||||
"field:utm_content_id": "120232007764490196",
|
||||
"field:utm_campaign": "Conversions_Hotel_Bemelmans_ITA",
|
||||
"field:utm_term": "Cold_Traffic_Conversions_Hotel_Bemelmans_ITA",
|
||||
"contactId": "bcc29403-82ac-445a-be52-90a67180f16f",
|
||||
"field:date_picker_a7c8": "2025-10-03",
|
||||
"field:angebot_auswaehlen": "Zimmer: Doppelzimmer",
|
||||
"field:utm_content": "Grafik_4_Spätsommer_23.08-07.09_Landingpage_ITA",
|
||||
"field:last_name_d97c": "Darman",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/1dea821c-8168-4736-96e4-4b92e8b364cf/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F1dea821c-8168-4736-96e4-4b92e8b364cf%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:gbraid": "",
|
||||
"field:fbclid": "PAZXh0bgNhZW0BMABhZGlkAasmYBTNE3QBp1jWuJ9zIpfEGRJMP63fMAMI405yvG5EtH-OT0PxSkAbBJaudFHR6cMtkdHu_aem_fopaFtECyVPNW9fmWfEkyA",
|
||||
"field:anrede": "Familie",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}
|
||||
},
|
||||
"origin_header": null,
|
||||
"all_headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "6638"
|
||||
}
|
||||
}
|
||||
262
logs/wix_test_data_20251006_104642.json
Normal file
262
logs/wix_test_data_20251006_104642.json
Normal file
@@ -0,0 +1,262 @@
|
||||
{
|
||||
"timestamp": "2025-10-06T10:46:42.527300",
|
||||
"client_ip": "127.0.0.1",
|
||||
"headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "7499"
|
||||
},
|
||||
"data": {
|
||||
"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Angebot auswählen",
|
||||
"value": "Zimmer: Doppelzimmer"
|
||||
},
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2025-12-21"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2025-10-28"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Herr"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Ernst-Dieter"
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Koepper"
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "koepper-ed@t-online.de"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+49 175 8555456"
|
||||
},
|
||||
{
|
||||
"label": "Message",
|
||||
"value": "Guten Morgen,\nwir sind nicht gebau an die Reisedaten gebunden: Anreise ist möglich ab 20. Dezember, Aufenthalt mindestens eine Woche, gern auch 8 oder 9 Tage. Natürlich mit Halbpension. Mit freundlichem Gruß D. Köpper"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Angekreuzt"
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": "5"
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": "23065043477"
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": "EAIaIQobChMI-d7Bn_-OkAMVuZJQBh09uD0vEAAYASAAEgKR8_D_BwE"
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "hotelid",
|
||||
"value": "12345"
|
||||
},
|
||||
{
|
||||
"label": "hotelname",
|
||||
"value": "Bemelmans Post"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2025-10-28",
|
||||
"field:number_7cf5": "2",
|
||||
"field:utm_source": "",
|
||||
"submissionTime": "2025-10-06T07:05:34.001Z",
|
||||
"field:gad_source": "5",
|
||||
"field:form_field_5a7b": "Angekreuzt",
|
||||
"field:gad_campaignid": "23065043477",
|
||||
"field:utm_medium": "",
|
||||
"field:utm_term_id": "",
|
||||
"context": {
|
||||
"metaSiteId": "1dea821c-8168-4736-96e4-4b92e8b364cf",
|
||||
"activationId": "fd8e9c90-0335-4fd2-976d-985f065f3f80"
|
||||
},
|
||||
"field:email_5139": "koepper-ed@t-online.de",
|
||||
"field:phone_4c77": "+49 175 8555456",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "fd8e9c90-0335-4fd2-976d-985f065f3f80"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "a976f18c-fa86-495d-be1e-676df188eeae"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "152db4d7-5263-40c4-be2b-1c81476318b7"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "EAIaIQobChMI-d7Bn_-OkAMVuZJQBh09uD0vEAAYASAAEgKR8_D_BwE",
|
||||
"formFieldMask": [
|
||||
"field:",
|
||||
"field:",
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"field:hotelid",
|
||||
"field:hotelname",
|
||||
"field:",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Ernst-Dieter",
|
||||
"last": "Koepper"
|
||||
},
|
||||
"email": "koepper-ed@t-online.de",
|
||||
"locale": "de-de",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+49 175 8555456",
|
||||
"id": "530a3bf4-6dbe-4611-8963-a50df805785d",
|
||||
"countryCode": "DE",
|
||||
"e164Phone": "+491758555456",
|
||||
"primary": true,
|
||||
"phone": "175 8555456"
|
||||
}
|
||||
],
|
||||
"contactId": "13659da8-4035-47fe-a66b-6ce461ad290f",
|
||||
"emails": [
|
||||
{
|
||||
"id": "e1d2168e-ca3c-4844-8f93-f2e1b0ae70e3",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "koepper-ed@t-online.de",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-10-06T07:05:35.675Z",
|
||||
"phone": "+491758555456",
|
||||
"createdDate": "2025-10-06T07:05:35.675Z"
|
||||
},
|
||||
"submissionId": "86d247dc-9d5a-4eb7-87a7-677bf64645ad",
|
||||
"field:anzahl_kinder": "0",
|
||||
"field:first_name_abae": "Ernst-Dieter",
|
||||
"field:utm_content_id": "",
|
||||
"field:utm_campaign": "",
|
||||
"field:utm_term": "",
|
||||
"contactId": "13659da8-4035-47fe-a66b-6ce461ad290f",
|
||||
"field:date_picker_a7c8": "2025-12-21",
|
||||
"field:hotelname": "Bemelmans Post",
|
||||
"field:angebot_auswaehlen": "Zimmer: Doppelzimmer",
|
||||
"field:utm_content": "",
|
||||
"field:last_name_d97c": "Koepper",
|
||||
"field:hotelid": "12345",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/1dea821c-8168-4736-96e4-4b92e8b364cf/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F1dea821c-8168-4736-96e4-4b92e8b364cf%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:gbraid": "",
|
||||
"field:fbclid": "",
|
||||
"submissionPdf": {
|
||||
"fileName": "86d247dc-9d5a-4eb7-87a7-677bf64645ad.pdf",
|
||||
"downloadUrl": "https://manage.wix.com/_api/form-submission-service/v4/submissions/86d247dc-9d5a-4eb7-87a7-677bf64645ad/download?accessToken=JWS.eyJraWQiOiJWLVNuLWhwZSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wibWV0YVNpdGVJZFwiOlwiMWRlYTgyMWMtODE2OC00NzM2LTk2ZTQtNGI5MmU4YjM2NGNmXCJ9IiwiaWF0IjoxNzU5NzM0MzM1LCJleHAiOjE3NTk3MzQ5MzV9.9koy-O_ptm0dRspjh01Yefkt2rCHiUlRCFtE_S3auYw"
|
||||
},
|
||||
"field:anrede": "Herr",
|
||||
"field:long_answer_3524": "Guten Morgen,\nwir sind nicht gebau an die Reisedaten gebunden: Anreise ist möglich ab 20. Dezember, Aufenthalt mindestens eine Woche, gern auch 8 oder 9 Tage. Natürlich mit Halbpension. Mit freundlichem Gruß D. Köpper",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}
|
||||
},
|
||||
"origin_header": null,
|
||||
"all_headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "7499"
|
||||
}
|
||||
}
|
||||
262
logs/wix_test_data_20251006_105732.json
Normal file
262
logs/wix_test_data_20251006_105732.json
Normal file
@@ -0,0 +1,262 @@
|
||||
{
|
||||
"timestamp": "2025-10-06T10:57:32.973217",
|
||||
"client_ip": "127.0.0.1",
|
||||
"headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "7499"
|
||||
},
|
||||
"data": {
|
||||
"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Angebot auswählen",
|
||||
"value": "Zimmer: Doppelzimmer"
|
||||
},
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2025-12-21"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2025-10-28"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Herr"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Ernst-Dieter"
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Koepper"
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "koepper-ed@t-online.de"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+49 175 8555456"
|
||||
},
|
||||
{
|
||||
"label": "Message",
|
||||
"value": "Guten Morgen,\nwir sind nicht gebau an die Reisedaten gebunden: Anreise ist möglich ab 20. Dezember, Aufenthalt mindestens eine Woche, gern auch 8 oder 9 Tage. Natürlich mit Halbpension. Mit freundlichem Gruß D. Köpper"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Angekreuzt"
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": "5"
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": "23065043477"
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": "EAIaIQobChMI-d7Bn_-OkAMVuZJQBh09uD0vEAAYASAAEgKR8_D_BwE"
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "hotelid",
|
||||
"value": "12345"
|
||||
},
|
||||
{
|
||||
"label": "hotelname",
|
||||
"value": "Bemelmans Post"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2025-10-28",
|
||||
"field:number_7cf5": "2",
|
||||
"field:utm_source": "",
|
||||
"submissionTime": "2025-10-06T07:05:34.001Z",
|
||||
"field:gad_source": "5",
|
||||
"field:form_field_5a7b": "Angekreuzt",
|
||||
"field:gad_campaignid": "23065043477",
|
||||
"field:utm_medium": "",
|
||||
"field:utm_term_id": "",
|
||||
"context": {
|
||||
"metaSiteId": "1dea821c-8168-4736-96e4-4b92e8b364cf",
|
||||
"activationId": "fd8e9c90-0335-4fd2-976d-985f065f3f80"
|
||||
},
|
||||
"field:email_5139": "koepper-ed@t-online.de",
|
||||
"field:phone_4c77": "+49 175 8555456",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "fd8e9c90-0335-4fd2-976d-985f065f3f80"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "a976f18c-fa86-495d-be1e-676df188eeae"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "152db4d7-5263-40c4-be2b-1c81476318b7"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "EAIaIQobChMI-d7Bn_-OkAMVuZJQBh09uD0vEAAYASAAEgKR8_D_BwE",
|
||||
"formFieldMask": [
|
||||
"field:",
|
||||
"field:",
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"field:hotelid",
|
||||
"field:hotelname",
|
||||
"field:",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Ernst-Dieter",
|
||||
"last": "Koepper"
|
||||
},
|
||||
"email": "koepper-ed@t-online.de",
|
||||
"locale": "de-de",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+49 175 8555456",
|
||||
"id": "530a3bf4-6dbe-4611-8963-a50df805785d",
|
||||
"countryCode": "DE",
|
||||
"e164Phone": "+491758555456",
|
||||
"primary": true,
|
||||
"phone": "175 8555456"
|
||||
}
|
||||
],
|
||||
"contactId": "13659da8-4035-47fe-a66b-6ce461ad290f",
|
||||
"emails": [
|
||||
{
|
||||
"id": "e1d2168e-ca3c-4844-8f93-f2e1b0ae70e3",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "koepper-ed@t-online.de",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-10-06T07:05:35.675Z",
|
||||
"phone": "+491758555456",
|
||||
"createdDate": "2025-10-06T07:05:35.675Z"
|
||||
},
|
||||
"submissionId": "86d247dc-9d5a-4eb7-87a7-677bf64645ad",
|
||||
"field:anzahl_kinder": "0",
|
||||
"field:first_name_abae": "Ernst-Dieter",
|
||||
"field:utm_content_id": "",
|
||||
"field:utm_campaign": "",
|
||||
"field:utm_term": "",
|
||||
"contactId": "13659da8-4035-47fe-a66b-6ce461ad290f",
|
||||
"field:date_picker_a7c8": "2025-12-21",
|
||||
"field:hotelname": "Bemelmans Post",
|
||||
"field:angebot_auswaehlen": "Zimmer: Doppelzimmer",
|
||||
"field:utm_content": "",
|
||||
"field:last_name_d97c": "Koepper",
|
||||
"field:hotelid": "12345",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/1dea821c-8168-4736-96e4-4b92e8b364cf/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F1dea821c-8168-4736-96e4-4b92e8b364cf%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:gbraid": "",
|
||||
"field:fbclid": "",
|
||||
"submissionPdf": {
|
||||
"fileName": "86d247dc-9d5a-4eb7-87a7-677bf64645ad.pdf",
|
||||
"downloadUrl": "https://manage.wix.com/_api/form-submission-service/v4/submissions/86d247dc-9d5a-4eb7-87a7-677bf64645ad/download?accessToken=JWS.eyJraWQiOiJWLVNuLWhwZSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wibWV0YVNpdGVJZFwiOlwiMWRlYTgyMWMtODE2OC00NzM2LTk2ZTQtNGI5MmU4YjM2NGNmXCJ9IiwiaWF0IjoxNzU5NzM0MzM1LCJleHAiOjE3NTk3MzQ5MzV9.9koy-O_ptm0dRspjh01Yefkt2rCHiUlRCFtE_S3auYw"
|
||||
},
|
||||
"field:anrede": "Herr",
|
||||
"field:long_answer_3524": "Guten Morgen,\nwir sind nicht gebau an die Reisedaten gebunden: Anreise ist möglich ab 20. Dezember, Aufenthalt mindestens eine Woche, gern auch 8 oder 9 Tage. Natürlich mit Halbpension. Mit freundlichem Gruß D. Köpper",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}
|
||||
},
|
||||
"origin_header": null,
|
||||
"all_headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "7499"
|
||||
}
|
||||
}
|
||||
262
logs/wix_test_data_20251006_154306.json
Normal file
262
logs/wix_test_data_20251006_154306.json
Normal file
@@ -0,0 +1,262 @@
|
||||
{
|
||||
"timestamp": "2025-10-06T15:43:06.732884",
|
||||
"client_ip": "127.0.0.1",
|
||||
"headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "7081"
|
||||
},
|
||||
"data": {
|
||||
"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Angebot auswählen",
|
||||
"value": "Zimmer: Doppelzimmer"
|
||||
},
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2025-10-21"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2025-12-28"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "4"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Herr"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Jonas"
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Linter"
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "jonas@vaius.ai"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+39 392 007 6982"
|
||||
},
|
||||
{
|
||||
"label": "Message",
|
||||
"value": "Hallo nachricht in der Kommentarsection"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Angekreuzt"
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": "5"
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": "23065043477"
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": "EAIaIQobChMI-d7Bn_-OkAMVuZJQBh09uD0vEAAYASAAEgKR8_D_BwE"
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "hotelid",
|
||||
"value": "12345"
|
||||
},
|
||||
{
|
||||
"label": "hotelname",
|
||||
"value": "Bemelmans Post"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2025-10-28",
|
||||
"field:number_7cf5": "2",
|
||||
"field:utm_source": "",
|
||||
"submissionTime": "2025-10-06T07:05:34.001Z",
|
||||
"field:gad_source": "5",
|
||||
"field:form_field_5a7b": "Angekreuzt",
|
||||
"field:gad_campaignid": "23065043477",
|
||||
"field:utm_medium": "",
|
||||
"field:utm_term_id": "",
|
||||
"context": {
|
||||
"metaSiteId": "1dea821c-8168-4736-96e4-4b92e8b364cf",
|
||||
"activationId": "fd8e9c90-0335-4fd2-976d-985f065f3f80"
|
||||
},
|
||||
"field:email_5139": "jonas@vaius.ai",
|
||||
"field:phone_4c77": "+39 392 007 6982",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "fd8e9c90-0335-4fd2-976d-985f065f3f80"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "a976f18c-fa86-495d-be1e-676df188eeae"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "152db4d7-5263-40c4-be2b-1c81476318b7"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "EAIaIQobChMI-d7Bn_-OkAMVuZJQBh09uD0vEAAYASAAEgKR8_D_BwE",
|
||||
"formFieldMask": [
|
||||
"field:",
|
||||
"field:",
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"field:hotelid",
|
||||
"field:hotelname",
|
||||
"field:",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Jonas",
|
||||
"last": "Linter"
|
||||
},
|
||||
"email": "jonas@vaius.ai",
|
||||
"locale": "de-de",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+39 392 007 6982",
|
||||
"id": "530a3bf4-6dbe-4611-8963-a50df805785d",
|
||||
"countryCode": "DE",
|
||||
"e164Phone": "+493920076982",
|
||||
"primary": true,
|
||||
"phone": "392 0076982"
|
||||
}
|
||||
],
|
||||
"contactId": "66659da8-4035-47fe-a66b-6ce461ad290f",
|
||||
"emails": [
|
||||
{
|
||||
"id": "e1d2168e-ca3c-4844-8f93-f2e1b0ae70e3",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "koepper-ed@t-online.de",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-10-06T07:05:35.675Z",
|
||||
"phone": "+491758555456",
|
||||
"createdDate": "2025-10-06T07:05:35.675Z"
|
||||
},
|
||||
"submissionId": "666247dc-9d5a-4eb7-87a7-677bf64645ad",
|
||||
"field:anzahl_kinder": "0",
|
||||
"field:first_name_abae": "Ernst-Dieter",
|
||||
"field:utm_content_id": "",
|
||||
"field:utm_campaign": "",
|
||||
"field:utm_term": "",
|
||||
"contactId": "66659da8-4035-47fe-a66b-6ce461ad290f",
|
||||
"field:date_picker_a7c8": "2025-12-21",
|
||||
"field:hotelname": "Testhotel",
|
||||
"field:angebot_auswaehlen": "Zimmer: Doppelzimmer",
|
||||
"field:utm_content": "",
|
||||
"field:last_name_d97c": "Linter",
|
||||
"field:hotelid": "135",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/1dea821c-8168-4736-96e4-4b92e8b364cf/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F1dea821c-8168-4736-96e4-4b92e8b364cf%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:gbraid": "",
|
||||
"field:fbclid": "",
|
||||
"submissionPdf": {
|
||||
"fileName": "86d247dc-9d5a-4eb7-87a7-677bf64645ad.pdf",
|
||||
"downloadUrl": "https://manage.wix.com/_api/form-submission-service/v4/submissions/86d247dc-9d5a-4eb7-87a7-677bf64645ad/download?accessToken=JWS.eyJraWQiOiJWLVNuLWhwZSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wibWV0YVNpdGVJZFwiOlwiMWRlYTgyMWMtODE2OC00NzM2LTk2ZTQtNGI5MmU4YjM2NGNmXCJ9IiwiaWF0IjoxNzU5NzM0MzM1LCJleHAiOjE3NTk3MzQ5MzV9.9koy-O_ptm0dRspjh01Yefkt2rCHiUlRCFtE_S3auYw"
|
||||
},
|
||||
"field:anrede": "Herr",
|
||||
"field:long_answer_3524": "Kommentarsektion vermutlich",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}
|
||||
},
|
||||
"origin_header": null,
|
||||
"all_headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "7081"
|
||||
}
|
||||
}
|
||||
262
logs/wix_test_data_20251006_154435.json
Normal file
262
logs/wix_test_data_20251006_154435.json
Normal file
@@ -0,0 +1,262 @@
|
||||
{
|
||||
"timestamp": "2025-10-06T15:44:35.341703",
|
||||
"client_ip": "127.0.0.1",
|
||||
"headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "7081"
|
||||
},
|
||||
"data": {
|
||||
"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Angebot auswählen",
|
||||
"value": "Zimmer: Doppelzimmer"
|
||||
},
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2025-10-21"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2025-12-28"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "4"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Herr"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Jonas"
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Linter"
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "jonas@vaius.ai"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+39 392 007 6982"
|
||||
},
|
||||
{
|
||||
"label": "Message",
|
||||
"value": "Hallo nachricht in der Kommentarsection"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Angekreuzt"
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": "5"
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": "23065043477"
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": "EAIaIQobChMI-d7Bn_-OkAMVuZJQBh09uD0vEAAYASAAEgKR8_D_BwE"
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "hotelid",
|
||||
"value": "12345"
|
||||
},
|
||||
{
|
||||
"label": "hotelname",
|
||||
"value": "Bemelmans Post"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2025-10-28",
|
||||
"field:number_7cf5": "2",
|
||||
"field:utm_source": "",
|
||||
"submissionTime": "2025-10-06T07:05:34.001Z",
|
||||
"field:gad_source": "5",
|
||||
"field:form_field_5a7b": "Angekreuzt",
|
||||
"field:gad_campaignid": "23065043477",
|
||||
"field:utm_medium": "",
|
||||
"field:utm_term_id": "",
|
||||
"context": {
|
||||
"metaSiteId": "1dea821c-8168-4736-96e4-4b92e8b364cf",
|
||||
"activationId": "fd8e9c90-0335-4fd2-976d-985f065f3f80"
|
||||
},
|
||||
"field:email_5139": "jonas@vaius.ai",
|
||||
"field:phone_4c77": "+39 392 007 6982",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "fd8e9c90-0335-4fd2-976d-985f065f3f80"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "a976f18c-fa86-495d-be1e-676df188eeae"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "152db4d7-5263-40c4-be2b-1c81476318b7"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "EAIaIQobChMI-d7Bn_-OkAMVuZJQBh09uD0vEAAYASAAEgKR8_D_BwE",
|
||||
"formFieldMask": [
|
||||
"field:",
|
||||
"field:",
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"field:hotelid",
|
||||
"field:hotelname",
|
||||
"field:",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Jonas",
|
||||
"last": "Linter"
|
||||
},
|
||||
"email": "jonas@vaius.ai",
|
||||
"locale": "de-de",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+39 392 007 6982",
|
||||
"id": "530a3bf4-6dbe-4611-8963-a50df805785d",
|
||||
"countryCode": "DE",
|
||||
"e164Phone": "+493920076982",
|
||||
"primary": true,
|
||||
"phone": "392 0076982"
|
||||
}
|
||||
],
|
||||
"contactId": "66659da8-4035-47fe-a66b-6ce461ad290f",
|
||||
"emails": [
|
||||
{
|
||||
"id": "e1d2168e-ca3c-4844-8f93-f2e1b0ae70e3",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "koepper-ed@t-online.de",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-10-06T07:05:35.675Z",
|
||||
"phone": "+491758555456",
|
||||
"createdDate": "2025-10-06T07:05:35.675Z"
|
||||
},
|
||||
"submissionId": "666247dc-9d5a-4eb7-87a7-677bf64645ad",
|
||||
"field:anzahl_kinder": "0",
|
||||
"field:first_name_abae": "Ernst-Dieter",
|
||||
"field:utm_content_id": "",
|
||||
"field:utm_campaign": "",
|
||||
"field:utm_term": "",
|
||||
"contactId": "66659da8-4035-47fe-a66b-6ce461ad290f",
|
||||
"field:date_picker_a7c8": "2025-12-21",
|
||||
"field:hotelname": "Testhotel",
|
||||
"field:angebot_auswaehlen": "Zimmer: Doppelzimmer",
|
||||
"field:utm_content": "",
|
||||
"field:last_name_d97c": "Linter",
|
||||
"field:hotelid": "135",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/1dea821c-8168-4736-96e4-4b92e8b364cf/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F1dea821c-8168-4736-96e4-4b92e8b364cf%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:gbraid": "",
|
||||
"field:fbclid": "",
|
||||
"submissionPdf": {
|
||||
"fileName": "86d247dc-9d5a-4eb7-87a7-677bf64645ad.pdf",
|
||||
"downloadUrl": "https://manage.wix.com/_api/form-submission-service/v4/submissions/86d247dc-9d5a-4eb7-87a7-677bf64645ad/download?accessToken=JWS.eyJraWQiOiJWLVNuLWhwZSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wibWV0YVNpdGVJZFwiOlwiMWRlYTgyMWMtODE2OC00NzM2LTk2ZTQtNGI5MmU4YjM2NGNmXCJ9IiwiaWF0IjoxNzU5NzM0MzM1LCJleHAiOjE3NTk3MzQ5MzV9.9koy-O_ptm0dRspjh01Yefkt2rCHiUlRCFtE_S3auYw"
|
||||
},
|
||||
"field:anrede": "Herr",
|
||||
"field:long_answer_3524": "Kommentarsektion vermutlich",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}
|
||||
},
|
||||
"origin_header": null,
|
||||
"all_headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "7081"
|
||||
}
|
||||
}
|
||||
257
logs/wix_test_data_20251007_155426.json
Normal file
257
logs/wix_test_data_20251007_155426.json
Normal file
@@ -0,0 +1,257 @@
|
||||
{
|
||||
"timestamp": "2025-10-07T15:54:26.898008",
|
||||
"client_ip": "127.0.0.1",
|
||||
"headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "7335"
|
||||
},
|
||||
"data": {
|
||||
"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2026-01-02"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2026-01-07"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "3"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"label": "Alter Kind 1",
|
||||
"value": "12"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Frau"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Genesia "
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Supino "
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "supinogenesia@gmail.com"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+39 340 625 9979"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Selezionato"
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": "fb"
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": "Facebook_Mobile_Feed"
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": "Conversions_Hotel_Bemelmans_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": "Cold_Traffic_Conversions_Hotel_Bemelmans_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": "Grafik_AuszeitDezember_9.12_23.12"
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": "120238574626400196"
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": "120238574626400196"
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": "IwZXh0bgNhZW0BMABhZGlkAassWPh1b8QBHoRc2S24gMktdNKiPwEvGYMK3rB-mne_0IJQvQRIGH60wLvLfOm0XWP8wJ9s_aem_rbpAFMODwOh4UnF5UVxwWg"
|
||||
},
|
||||
{
|
||||
"label": "hotelid",
|
||||
"value": "12345"
|
||||
},
|
||||
{
|
||||
"label": "hotelname",
|
||||
"value": "Bemelmans Post"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2026-01-07",
|
||||
"field:number_7cf5": "3",
|
||||
"field:utm_source": "fb",
|
||||
"submissionTime": "2025-10-07T05:48:41.855Z",
|
||||
"field:alter_kind_3": "12",
|
||||
"field:gad_source": "",
|
||||
"field:form_field_5a7b": "Selezionato",
|
||||
"field:gad_campaignid": "",
|
||||
"field:utm_medium": "Facebook_Mobile_Feed",
|
||||
"field:utm_term_id": "120238574626400196",
|
||||
"context": {
|
||||
"metaSiteId": "1dea821c-8168-4736-96e4-4b92e8b364cf",
|
||||
"activationId": "2421c9cd-6565-49ba-b60f-165d3dacccba"
|
||||
},
|
||||
"field:email_5139": "supinogenesia@gmail.com",
|
||||
"field:phone_4c77": "+39 340 625 9979",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "2421c9cd-6565-49ba-b60f-165d3dacccba"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "a976f18c-fa86-495d-be1e-676df188eeae"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "152db4d7-5263-40c4-be2b-1c81476318b7"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "",
|
||||
"formFieldMask": [
|
||||
"field:",
|
||||
"field:",
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"field:hotelid",
|
||||
"field:hotelname",
|
||||
"field:",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Genesia",
|
||||
"last": "Supino"
|
||||
},
|
||||
"email": "supinogenesia@gmail.com",
|
||||
"locale": "it-it",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+39 340 625 9979",
|
||||
"id": "198f04fb-5b2c-4a7b-b7ea-adc150ec4212",
|
||||
"countryCode": "IT",
|
||||
"e164Phone": "+393406259979",
|
||||
"primary": true,
|
||||
"phone": "340 625 9979"
|
||||
}
|
||||
],
|
||||
"contactId": "4d695011-36c1-4480-b225-ae9c6eef9e83",
|
||||
"emails": [
|
||||
{
|
||||
"id": "e09d7bab-1f11-4b5d-b3c5-32d43c1dc584",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "supinogenesia@gmail.com",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-10-07T05:48:44.764Z",
|
||||
"phone": "+393406259979",
|
||||
"createdDate": "2025-10-07T05:48:43.567Z"
|
||||
},
|
||||
"submissionId": "c52702c9-55b9-44e1-b158-ec9544c73cc7",
|
||||
"field:anzahl_kinder": "1",
|
||||
"field:first_name_abae": "Genesia ",
|
||||
"field:utm_content_id": "120238574626400196",
|
||||
"field:utm_campaign": "Conversions_Hotel_Bemelmans_ITA",
|
||||
"field:utm_term": "Cold_Traffic_Conversions_Hotel_Bemelmans_ITA",
|
||||
"contactId": "4d695011-36c1-4480-b225-ae9c6eef9e83",
|
||||
"field:date_picker_a7c8": "2026-01-02",
|
||||
"field:hotelname": "Bemelmans Post",
|
||||
"field:utm_content": "Grafik_AuszeitDezember_9.12_23.12",
|
||||
"field:last_name_d97c": "Supino ",
|
||||
"field:hotelid": "12345",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/1dea821c-8168-4736-96e4-4b92e8b364cf/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F1dea821c-8168-4736-96e4-4b92e8b364cf%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:gbraid": "",
|
||||
"field:fbclid": "IwZXh0bgNhZW0BMABhZGlkAassWPh1b8QBHoRc2S24gMktdNKiPwEvGYMK3rB-mne_0IJQvQRIGH60wLvLfOm0XWP8wJ9s_aem_rbpAFMODwOh4UnF5UVxwWg",
|
||||
"submissionPdf": {
|
||||
"fileName": "c52702c9-55b9-44e1-b158-ec9544c73cc7.pdf",
|
||||
"downloadUrl": "https://manage.wix.com/_api/form-submission-service/v4/submissions/c52702c9-55b9-44e1-b158-ec9544c73cc7/download?accessToken=JWS.eyJraWQiOiJWLVNuLWhwZSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wibWV0YVNpdGVJZFwiOlwiMWRlYTgyMWMtODE2OC00NzM2LTk2ZTQtNGI5MmU4YjM2NGNmXCJ9IiwiaWF0IjoxNzU5ODE2MTI0LCJleHAiOjE3NTk4MTY3MjR9.quBfp9UL9Ddqb2CWERXoVkh9OdmHlIBvlLAyhoXElaY"
|
||||
},
|
||||
"field:anrede": "Frau",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}
|
||||
},
|
||||
"origin_header": null,
|
||||
"all_headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "7335"
|
||||
}
|
||||
}
|
||||
257
logs/wix_test_data_20251007_160537.json
Normal file
257
logs/wix_test_data_20251007_160537.json
Normal file
@@ -0,0 +1,257 @@
|
||||
{
|
||||
"timestamp": "2025-10-07T16:05:37.531417",
|
||||
"client_ip": "127.0.0.1",
|
||||
"headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "7335"
|
||||
},
|
||||
"data": {
|
||||
"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2026-01-02"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2026-01-07"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "3"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"label": "Alter Kind 1",
|
||||
"value": "12"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Frau"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Genesia "
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Supino "
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "supinogenesia@gmail.com"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+39 340 625 9979"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Selezionato"
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": "fb"
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": "Facebook_Mobile_Feed"
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": "Conversions_Hotel_Bemelmans_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": "Cold_Traffic_Conversions_Hotel_Bemelmans_ITA"
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": "Grafik_AuszeitDezember_9.12_23.12"
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": "120238574626400196"
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": "120238574626400196"
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": "IwZXh0bgNhZW0BMABhZGlkAassWPh1b8QBHoRc2S24gMktdNKiPwEvGYMK3rB-mne_0IJQvQRIGH60wLvLfOm0XWP8wJ9s_aem_rbpAFMODwOh4UnF5UVxwWg"
|
||||
},
|
||||
{
|
||||
"label": "hotelid",
|
||||
"value": "12345"
|
||||
},
|
||||
{
|
||||
"label": "hotelname",
|
||||
"value": "Bemelmans Post"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2026-01-07",
|
||||
"field:number_7cf5": "3",
|
||||
"field:utm_source": "fb",
|
||||
"submissionTime": "2025-10-07T05:48:41.855Z",
|
||||
"field:alter_kind_3": "12",
|
||||
"field:gad_source": "",
|
||||
"field:form_field_5a7b": "Selezionato",
|
||||
"field:gad_campaignid": "",
|
||||
"field:utm_medium": "Facebook_Mobile_Feed",
|
||||
"field:utm_term_id": "120238574626400196",
|
||||
"context": {
|
||||
"metaSiteId": "1dea821c-8168-4736-96e4-4b92e8b364cf",
|
||||
"activationId": "2421c9cd-6565-49ba-b60f-165d3dacccba"
|
||||
},
|
||||
"field:email_5139": "supinogenesia@gmail.com",
|
||||
"field:phone_4c77": "+39 340 625 9979",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "2421c9cd-6565-49ba-b60f-165d3dacccba"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "a976f18c-fa86-495d-be1e-676df188eeae"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "152db4d7-5263-40c4-be2b-1c81476318b7"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "",
|
||||
"formFieldMask": [
|
||||
"field:",
|
||||
"field:",
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"field:hotelid",
|
||||
"field:hotelname",
|
||||
"field:",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Genesia",
|
||||
"last": "Supino"
|
||||
},
|
||||
"email": "supinogenesia@gmail.com",
|
||||
"locale": "it-it",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+39 340 625 9979",
|
||||
"id": "198f04fb-5b2c-4a7b-b7ea-adc150ec4212",
|
||||
"countryCode": "IT",
|
||||
"e164Phone": "+393406259979",
|
||||
"primary": true,
|
||||
"phone": "340 625 9979"
|
||||
}
|
||||
],
|
||||
"contactId": "4d695011-36c1-4480-b225-ae9c6eef9e83",
|
||||
"emails": [
|
||||
{
|
||||
"id": "e09d7bab-1f11-4b5d-b3c5-32d43c1dc584",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "supinogenesia@gmail.com",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-10-07T05:48:44.764Z",
|
||||
"phone": "+393406259979",
|
||||
"createdDate": "2025-10-07T05:48:43.567Z"
|
||||
},
|
||||
"submissionId": "c52702c9-55b9-44e1-b158-ec9544c73cc7",
|
||||
"field:anzahl_kinder": "1",
|
||||
"field:first_name_abae": "Genesia ",
|
||||
"field:utm_content_id": "120238574626400196",
|
||||
"field:utm_campaign": "Conversions_Hotel_Bemelmans_ITA",
|
||||
"field:utm_term": "Cold_Traffic_Conversions_Hotel_Bemelmans_ITA",
|
||||
"contactId": "4d695011-36c1-4480-b225-ae9c6eef9e83",
|
||||
"field:date_picker_a7c8": "2026-01-02",
|
||||
"field:hotelname": "Bemelmans Post",
|
||||
"field:utm_content": "Grafik_AuszeitDezember_9.12_23.12",
|
||||
"field:last_name_d97c": "Supino ",
|
||||
"field:hotelid": "12345",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/1dea821c-8168-4736-96e4-4b92e8b364cf/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F1dea821c-8168-4736-96e4-4b92e8b364cf%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:gbraid": "",
|
||||
"field:fbclid": "IwZXh0bgNhZW0BMABhZGlkAassWPh1b8QBHoRc2S24gMktdNKiPwEvGYMK3rB-mne_0IJQvQRIGH60wLvLfOm0XWP8wJ9s_aem_rbpAFMODwOh4UnF5UVxwWg",
|
||||
"submissionPdf": {
|
||||
"fileName": "c52702c9-55b9-44e1-b158-ec9544c73cc7.pdf",
|
||||
"downloadUrl": "https://manage.wix.com/_api/form-submission-service/v4/submissions/c52702c9-55b9-44e1-b158-ec9544c73cc7/download?accessToken=JWS.eyJraWQiOiJWLVNuLWhwZSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wibWV0YVNpdGVJZFwiOlwiMWRlYTgyMWMtODE2OC00NzM2LTk2ZTQtNGI5MmU4YjM2NGNmXCJ9IiwiaWF0IjoxNzU5ODE2MTI0LCJleHAiOjE3NTk4MTY3MjR9.quBfp9UL9Ddqb2CWERXoVkh9OdmHlIBvlLAyhoXElaY"
|
||||
},
|
||||
"field:anrede": "Frau",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}
|
||||
},
|
||||
"origin_header": null,
|
||||
"all_headers": {
|
||||
"host": "localhost:8080",
|
||||
"content-type": "application/json",
|
||||
"user-agent": "insomnia/2023.5.8",
|
||||
"accept": "*/*",
|
||||
"content-length": "7335"
|
||||
}
|
||||
}
|
||||
42
output.xml
42
output.xml
@@ -1,13 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_ResRetrieveRS xmlns="http://www.opentravel.org/OTA/2003/05" Version="7.000">
|
||||
<ReservationsList>
|
||||
<HotelReservation CreateDateTime="2025-09-25T13:33:19.275224+00:00" ResStatus="Requested" RoomStayReservation="true">
|
||||
<UniqueID Type="14" ID="6b34fe24ac2ff811"/>
|
||||
<HotelReservation CreateDateTime="2025-09-29T12:08:55.313540+00:00" ResStatus="Requested" RoomStayReservation="true">
|
||||
<UniqueID Type="14" ID="e084006b-ae83-4e4d-b2f5-074118cdb3b1"/>
|
||||
<RoomStays>
|
||||
<RoomStay>
|
||||
<TimeSpan>
|
||||
<StartDateWindow EarliestDate="2024-10-01" LatestDate="2024-10-02"/>
|
||||
</TimeSpan>
|
||||
<GuestCounts>
|
||||
<GuestCount Count="2"/>
|
||||
<GuestCount Count="1" Age="3"/>
|
||||
<GuestCount Count="1" Age="0"/>
|
||||
<GuestCount Count="1" Age="1"/>
|
||||
</GuestCounts>
|
||||
<TimeSpan Start="2025-10-31" End="2025-11-02"/>
|
||||
</RoomStay>
|
||||
</RoomStays>
|
||||
<ResGuests>
|
||||
@@ -15,21 +19,14 @@
|
||||
<Profiles>
|
||||
<ProfileInfo>
|
||||
<Profile>
|
||||
<Customer Gender="Male" BirthDate="1980-01-01" Language="en">
|
||||
<Customer Language="it">
|
||||
<PersonName>
|
||||
<NamePrefix>Mr.</NamePrefix>
|
||||
<GivenName>John</GivenName>
|
||||
<Surname>Doe</Surname>
|
||||
<NamePrefix>Frau</NamePrefix>
|
||||
<GivenName>Elena</GivenName>
|
||||
<Surname>Battiloro</Surname>
|
||||
</PersonName>
|
||||
<Telephone PhoneTechType="5" PhoneNumber="+1234567890"/>
|
||||
<Telephone PhoneNumber="+0987654321"/>
|
||||
<Email Remark="newsletter:yes">john.doe@example.com</Email>
|
||||
<Address Remark="catalog:no">
|
||||
<AddressLine>123 Main Street</AddressLine>
|
||||
<CityName>Anytown</CityName>
|
||||
<PostalCode>12345</PostalCode>
|
||||
<CountryName Code="US"/>
|
||||
</Address>
|
||||
<Telephone PhoneTechType="5" PhoneNumber="+393337673262"/>
|
||||
<Email Remark="newsletter:no">e.battiloro1@gmail.com</Email>
|
||||
</Customer>
|
||||
</Profile>
|
||||
</ProfileInfo>
|
||||
@@ -38,16 +35,13 @@
|
||||
</ResGuests>
|
||||
<ResGlobalInfo>
|
||||
<Comments>
|
||||
<Comment Name="customer comment">
|
||||
<ListItem ListItem="1" Language="en">Landing page comment</ListItem>
|
||||
<Text>This is a sample comment.</Text>
|
||||
</Comment>
|
||||
<Comment Name="additional info">
|
||||
<Text>This is a special request comment.</Text>
|
||||
<ListItem ListItem="1" Language="it">Herbstferien - Familienzeit mit Dolomitenblick</ListItem>
|
||||
<Text>Angebot/Offerta</Text>
|
||||
</Comment>
|
||||
</Comments>
|
||||
<HotelReservationIDs>
|
||||
<HotelReservationID ResID_Type="13" ResID_SourceContext="99tales"/>
|
||||
<HotelReservationID ResID_Type="13" ResID_Value="PAZXh0bgNhZW0BMABhZGlkAasmYBhk4DQBp02L46Rl1jAuccxsOaeFSv7WSFnP-MQCsOrz9yDnKRH4hwZ7GEgxF9gy0_OF_aem_qSvrs6xsBkvTaI_Y9_hfnQ" ResID_SourceContext="99tales"/>
|
||||
</HotelReservationIDs>
|
||||
<BasicPropertyInfo HotelCode="123" HotelName="Frangart Inn"/>
|
||||
</ResGlobalInfo>
|
||||
|
||||
129
pyproject.toml
129
pyproject.toml
@@ -4,15 +4,27 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "alpine-bits-python-server"
|
||||
version = "0.1.0"
|
||||
version = "0.1.2"
|
||||
description = "Alpine Bits Python Server implementation"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.13"
|
||||
dependencies = [
|
||||
"aiosqlite>=0.21.0",
|
||||
"annotatedyaml>=1.0.0",
|
||||
"dotenv>=0.9.9",
|
||||
"fastapi>=0.117.1",
|
||||
"generateds>=2.44.3",
|
||||
"httpx>=0.28.1",
|
||||
"lxml>=6.0.1",
|
||||
"pydantic[email]>=2.11.9",
|
||||
"pytest>=8.4.2",
|
||||
"pytest-asyncio>=1.2.0",
|
||||
"redis>=6.4.0",
|
||||
"ruff>=0.13.1",
|
||||
"slowapi>=0.1.9",
|
||||
"sqlalchemy>=2.0.43",
|
||||
"uvicorn>=0.37.0",
|
||||
"voluptuous>=0.15.2",
|
||||
"xsdata-pydantic[cli,lxml,soap]>=24.5",
|
||||
"xsdata[cli,lxml,soap]>=25.7",
|
||||
]
|
||||
@@ -24,8 +36,119 @@ alpine-bits-server = "alpine_bits_python.main:main"
|
||||
packages = ["src/alpine_bits_python"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["test"]
|
||||
testpaths = ["tests"]
|
||||
pythonpath = ["src"]
|
||||
|
||||
[tool.ruff]
|
||||
src = ["src", "test"]
|
||||
src = ["src", "tests"]
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
"A001", # Variable {name} is shadowing a Python builtin
|
||||
"ASYNC210", # Async functions should not call blocking HTTP methods
|
||||
"ASYNC220", # Async functions should not create subprocesses with blocking methods
|
||||
"ASYNC221", # Async functions should not run processes with blocking methods
|
||||
"ASYNC222", # Async functions should not wait on processes with blocking methods
|
||||
"ASYNC230", # Async functions should not open files with blocking methods like open
|
||||
"ASYNC251", # Async functions should not call time.sleep
|
||||
"B002", # Python does not support the unary prefix increment
|
||||
"B005", # Using .strip() with multi-character strings is misleading
|
||||
"B007", # Loop control variable {name} not used within loop body
|
||||
"B014", # Exception handler with duplicate exception
|
||||
"B015", # Pointless comparison. Did you mean to assign a value? Otherwise, prepend assert or remove it.
|
||||
"B017", # pytest.raises(BaseException) should be considered evil
|
||||
"B018", # Found useless attribute access. Either assign it to a variable or remove it.
|
||||
"B023", # Function definition does not bind loop variable {name}
|
||||
"B024", # `{name}` is an abstract base class, but it has no abstract methods or properties
|
||||
"B026", # Star-arg unpacking after a keyword argument is strongly discouraged
|
||||
"B032", # Possible unintentional type annotation (using :). Did you mean to assign (using =)?
|
||||
"B035", # Dictionary comprehension uses static key
|
||||
"B904", # Use raise from to specify exception cause
|
||||
"B905", # zip() without an explicit strict= parameter
|
||||
"BLE",
|
||||
"C", # complexity
|
||||
"COM818", # Trailing comma on bare tuple prohibited
|
||||
"D", # docstrings
|
||||
"DTZ003", # Use datetime.now(tz=) instead of datetime.utcnow()
|
||||
"DTZ004", # Use datetime.fromtimestamp(ts, tz=) instead of datetime.utcfromtimestamp(ts)
|
||||
"E", # pycodestyle
|
||||
"F", # pyflakes/autoflake
|
||||
"F541", # f-string without any placeholders
|
||||
"FLY", # flynt
|
||||
"FURB", # refurb
|
||||
"G", # flake8-logging-format
|
||||
"I", # isort
|
||||
"INP", # flake8-no-pep420
|
||||
"ISC", # flake8-implicit-str-concat
|
||||
"ICN001", # import concentions; {name} should be imported as {asname}
|
||||
"LOG", # flake8-logging
|
||||
"N804", # First argument of a class method should be named cls
|
||||
"N805", # First argument of a method should be named self
|
||||
"N815", # Variable {name} in class scope should not be mixedCase
|
||||
"PERF", # Perflint
|
||||
"PGH", # pygrep-hooks
|
||||
"PIE", # flake8-pie
|
||||
"PL", # pylint
|
||||
"PT", # flake8-pytest-style
|
||||
"PTH", # flake8-pathlib
|
||||
"PYI", # flake8-pyi
|
||||
"RET", # flake8-return
|
||||
"RSE", # flake8-raise
|
||||
"RUF005", # Consider iterable unpacking instead of concatenation
|
||||
"RUF006", # Store a reference to the return value of asyncio.create_task
|
||||
"RUF007", # Prefer itertools.pairwise() over zip() when iterating over successive pairs
|
||||
"RUF008", # Do not use mutable default values for dataclass attributes
|
||||
"RUF010", # Use explicit conversion flag
|
||||
"RUF013", # PEP 484 prohibits implicit Optional
|
||||
"RUF016", # Slice in indexed access to type {value_type} uses type {index_type} instead of an integer
|
||||
"RUF017", # Avoid quadratic list summation
|
||||
"RUF018", # Avoid assignment expressions in assert statements
|
||||
"RUF019", # Unnecessary key check before dictionary access
|
||||
"RUF020", # {never_like} | T is equivalent to T
|
||||
"RUF021", # Parenthesize a and b expressions when chaining and and or together, to make the precedence clear
|
||||
"RUF022", # Sort __all__
|
||||
"RUF023", # Sort __slots__
|
||||
"RUF024", # Do not pass mutable objects as values to dict.fromkeys
|
||||
"RUF026", # default_factory is a positional-only argument to defaultdict
|
||||
"RUF030", # print() call in assert statement is likely unintentional
|
||||
"RUF032", # Decimal() called with float literal argument
|
||||
"RUF033", # __post_init__ method with argument defaults
|
||||
"RUF034", # Useless if-else condition
|
||||
"RUF100", # Unused `noqa` directive
|
||||
"RUF101", # noqa directives that use redirected rule codes
|
||||
"RUF200", # Failed to parse pyproject.toml: {message}
|
||||
"S102", # Use of exec detected
|
||||
"S103", # bad-file-permissions
|
||||
"S108", # hardcoded-temp-file
|
||||
"S306", # suspicious-mktemp-usage
|
||||
"S307", # suspicious-eval-usage
|
||||
"S313", # suspicious-xmlc-element-tree-usage
|
||||
"S314", # suspicious-xml-element-tree-usage
|
||||
"S315", # suspicious-xml-expat-reader-usage
|
||||
"S316", # suspicious-xml-expat-builder-usage
|
||||
"S317", # suspicious-xml-sax-usage
|
||||
"S318", # suspicious-xml-mini-dom-usage
|
||||
"S319", # suspicious-xml-pull-dom-usage
|
||||
"S601", # paramiko-call
|
||||
"S602", # subprocess-popen-with-shell-equals-true
|
||||
"S604", # call-with-shell-equals-true
|
||||
"S608", # hardcoded-sql-expression
|
||||
"S609", # unix-command-wildcard-injection
|
||||
"SIM", # flake8-simplify
|
||||
"SLF", # flake8-self
|
||||
"SLOT", # flake8-slots
|
||||
"T100", # Trace found: {name} used
|
||||
"T20", # flake8-print
|
||||
"TC", # flake8-type-checking
|
||||
"TID", # Tidy imports
|
||||
"TRY", # tryceratops
|
||||
"UP", # pyupgrade
|
||||
"UP031", # Use format specifiers instead of percent format
|
||||
"UP032", # Use f-string instead of `format` call
|
||||
"W", # pycodestyle
|
||||
]
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"pytest-cov>=7.0.0",
|
||||
]
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
"""AlpineBits Python Server package."""
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
"""Entry point for alpine_bits_python package."""
|
||||
from .main import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
886
src/alpine_bits_python/alpine_bits_helpers.py
Normal file
886
src/alpine_bits_python/alpine_bits_helpers.py
Normal file
@@ -0,0 +1,886 @@
|
||||
import traceback
|
||||
from dataclasses import dataclass
|
||||
from datetime import UTC
|
||||
from enum import Enum
|
||||
from typing import Any
|
||||
|
||||
from alpine_bits_python.db import Customer, Reservation
|
||||
from alpine_bits_python.logging_config import get_logger
|
||||
from alpine_bits_python.schemas import (
|
||||
CommentData,
|
||||
CommentListItemData,
|
||||
CommentsData,
|
||||
CustomerData,
|
||||
HotelReservationIdData,
|
||||
PhoneTechType,
|
||||
)
|
||||
|
||||
# Import the generated classes
|
||||
from .generated.alpinebits import (
|
||||
CommentName2,
|
||||
HotelReservationResStatus,
|
||||
OtaHotelResNotifRq,
|
||||
OtaResRetrieveRs,
|
||||
ProfileProfileType,
|
||||
UniqueIdType2,
|
||||
)
|
||||
|
||||
_LOGGER = get_logger(__name__)
|
||||
|
||||
# Define type aliases for the two Customer types
|
||||
NotifCustomer = OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGuests.ResGuest.Profiles.ProfileInfo.Profile.Customer # noqa: E501
|
||||
RetrieveCustomer = OtaResRetrieveRs.ReservationsList.HotelReservation.ResGuests.ResGuest.Profiles.ProfileInfo.Profile.Customer # noqa: E501
|
||||
|
||||
# Define type aliases for HotelReservationId types
|
||||
NotifHotelReservationId = OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGlobalInfo.HotelReservationIds.HotelReservationId # noqa: E501
|
||||
RetrieveHotelReservationId = OtaResRetrieveRs.ReservationsList.HotelReservation.ResGlobalInfo.HotelReservationIds.HotelReservationId # noqa: E501
|
||||
|
||||
# Define type aliases for Comments types
|
||||
NotifComments = (
|
||||
OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGlobalInfo.Comments
|
||||
)
|
||||
RetrieveComments = (
|
||||
OtaResRetrieveRs.ReservationsList.HotelReservation.ResGlobalInfo.Comments
|
||||
)
|
||||
NotifComment = (
|
||||
OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGlobalInfo.Comments.Comment
|
||||
)
|
||||
RetrieveComment = (
|
||||
OtaResRetrieveRs.ReservationsList.HotelReservation.ResGlobalInfo.Comments.Comment
|
||||
)
|
||||
|
||||
# type aliases for GuestCounts
|
||||
NotifGuestCounts = (
|
||||
OtaHotelResNotifRq.HotelReservations.HotelReservation.RoomStays.RoomStay.GuestCounts
|
||||
)
|
||||
RetrieveGuestCounts = (
|
||||
OtaResRetrieveRs.ReservationsList.HotelReservation.RoomStays.RoomStay.GuestCounts
|
||||
)
|
||||
|
||||
NotifUniqueId = OtaHotelResNotifRq.HotelReservations.HotelReservation.UniqueId
|
||||
RetrieveUniqueId = OtaResRetrieveRs.ReservationsList.HotelReservation.UniqueId
|
||||
|
||||
NotifTimeSpan = (
|
||||
OtaHotelResNotifRq.HotelReservations.HotelReservation.RoomStays.RoomStay.TimeSpan
|
||||
)
|
||||
RetrieveTimeSpan = (
|
||||
OtaResRetrieveRs.ReservationsList.HotelReservation.RoomStays.RoomStay.TimeSpan
|
||||
)
|
||||
|
||||
NotifRoomStays = OtaHotelResNotifRq.HotelReservations.HotelReservation.RoomStays
|
||||
RetrieveRoomStays = OtaResRetrieveRs.ReservationsList.HotelReservation.RoomStays
|
||||
|
||||
NotifHotelReservation = OtaHotelResNotifRq.HotelReservations.HotelReservation
|
||||
RetrieveHotelReservation = OtaResRetrieveRs.ReservationsList.HotelReservation
|
||||
|
||||
from .const import RESERVATION_ID_TYPE
|
||||
|
||||
|
||||
# Enum to specify which OTA message type to use
|
||||
class OtaMessageType(Enum):
|
||||
NOTIF = "notification" # For OtaHotelResNotifRq
|
||||
RETRIEVE = "retrieve" # For OtaResRetrieveRs
|
||||
|
||||
|
||||
@dataclass
|
||||
class KidsAgeData:
|
||||
"""Data class to hold information about children's ages."""
|
||||
|
||||
ages: list[int]
|
||||
|
||||
|
||||
class GuestCountsFactory:
|
||||
"""Factory class to create GuestCounts instances for both OtaHotelResNotifRq and OtaResRetrieveRs."""
|
||||
|
||||
@staticmethod
|
||||
def create_guest_counts(
|
||||
adults: int,
|
||||
kids: list[int] | None = None,
|
||||
message_type: OtaMessageType = OtaMessageType.RETRIEVE,
|
||||
) -> NotifGuestCounts:
|
||||
"""Create a GuestCounts object for OtaHotelResNotifRq or OtaResRetrieveRs.
|
||||
|
||||
:param adults: Number of adults
|
||||
:param kids: List of ages for each kid (optional)
|
||||
:return: GuestCounts instance
|
||||
"""
|
||||
if message_type == OtaMessageType.RETRIEVE:
|
||||
return GuestCountsFactory._create_guest_counts(
|
||||
adults, kids, RetrieveGuestCounts
|
||||
)
|
||||
if message_type == OtaMessageType.NOTIF:
|
||||
return GuestCountsFactory._create_guest_counts(
|
||||
adults, kids, NotifGuestCounts
|
||||
)
|
||||
raise ValueError(f"Unsupported message type: {message_type}")
|
||||
|
||||
@staticmethod
|
||||
def _create_guest_counts(
|
||||
adults: int, kids: list[int] | None, guest_counts_class: type
|
||||
) -> Any:
|
||||
"""Create a GuestCounts object of the specified type.
|
||||
|
||||
:param adults: Number of adults
|
||||
:param kids: List of ages for each kid (optional)
|
||||
:param guest_counts_class: The GuestCounts class to instantiate
|
||||
:return: GuestCounts instance
|
||||
"""
|
||||
GuestCount = guest_counts_class.GuestCount
|
||||
guest_count_list = []
|
||||
if adults > 0:
|
||||
guest_count_list.append(GuestCount(count=str(adults)))
|
||||
if kids:
|
||||
# create a dict with amount of kids for each age
|
||||
age_count = {}
|
||||
|
||||
for age in kids:
|
||||
if age in age_count:
|
||||
age_count[age] += 1
|
||||
else:
|
||||
age_count[age] = 1
|
||||
|
||||
for age, count in age_count.items():
|
||||
guest_count_list.append(GuestCount(count=str(count), age=str(age)))
|
||||
return guest_counts_class(guest_count=guest_count_list)
|
||||
|
||||
|
||||
class CustomerFactory:
|
||||
"""Factory class to create Customer instances for both Retrieve and Notif."""
|
||||
|
||||
@staticmethod
|
||||
def create_notif_customer(data: CustomerData) -> NotifCustomer:
|
||||
"""Create a Customer for OtaHotelResNotifRq."""
|
||||
return CustomerFactory._create_customer(NotifCustomer, data)
|
||||
|
||||
@staticmethod
|
||||
def create_retrieve_customer(data: CustomerData) -> RetrieveCustomer:
|
||||
"""Create a Customer for OtaResRetrieveRs."""
|
||||
return CustomerFactory._create_customer(RetrieveCustomer, data)
|
||||
|
||||
@staticmethod
|
||||
def _create_customer(
|
||||
customer_class: type[RetrieveCustomer | NotifCustomer], data: CustomerData
|
||||
) -> Any:
|
||||
"""Create a customer of the specified type."""
|
||||
# Create PersonName
|
||||
person_name = customer_class.PersonName(
|
||||
given_name=data.given_name,
|
||||
surname=data.surname,
|
||||
name_prefix=data.name_prefix,
|
||||
name_title=data.name_title,
|
||||
)
|
||||
|
||||
# Create telephone list
|
||||
telephones = []
|
||||
for phone_number, phone_tech_type in data.phone_numbers:
|
||||
telephone = customer_class.Telephone(
|
||||
phone_number=phone_number,
|
||||
phone_tech_type=phone_tech_type.value if phone_tech_type else None,
|
||||
)
|
||||
telephones.append(telephone)
|
||||
|
||||
# Create email if provided
|
||||
email = None
|
||||
if data.email_address:
|
||||
remark = None
|
||||
if data.email_newsletter is not None:
|
||||
remark = f"newsletter:{'yes' if data.email_newsletter else 'no'}"
|
||||
|
||||
email = customer_class.Email(value=data.email_address, remark=remark)
|
||||
|
||||
# Create address if any address fields are provided
|
||||
address = None
|
||||
if any(
|
||||
[data.address_line, data.city_name, data.postal_code, data.country_code]
|
||||
):
|
||||
country_name = None
|
||||
if data.country_code:
|
||||
country_name = customer_class.Address.CountryName(
|
||||
code=data.country_code
|
||||
)
|
||||
|
||||
address_remark = None
|
||||
if data.address_catalog is not None:
|
||||
address_remark = f"catalog:{'yes' if data.address_catalog else 'no'}"
|
||||
|
||||
address = customer_class.Address(
|
||||
address_line=data.address_line,
|
||||
city_name=data.city_name,
|
||||
postal_code=data.postal_code,
|
||||
country_name=country_name,
|
||||
remark=address_remark,
|
||||
)
|
||||
|
||||
# Create the customer
|
||||
return customer_class(
|
||||
person_name=person_name,
|
||||
telephone=telephones,
|
||||
email=email,
|
||||
address=address,
|
||||
gender=data.gender,
|
||||
birth_date=data.birth_date,
|
||||
language=data.language,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_notif_customer(customer: NotifCustomer) -> CustomerData:
|
||||
"""Convert a NotifCustomer back to CustomerData."""
|
||||
return CustomerFactory._customer_to_data(customer)
|
||||
|
||||
@staticmethod
|
||||
def from_retrieve_customer(customer: RetrieveCustomer) -> CustomerData:
|
||||
"""Convert a RetrieveCustomer back to CustomerData."""
|
||||
return CustomerFactory._customer_to_data(customer)
|
||||
|
||||
@staticmethod
|
||||
def _customer_to_data(customer: Any) -> CustomerData:
|
||||
"""Convert any customer type to CustomerData."""
|
||||
# Extract phone numbers
|
||||
phone_numbers = []
|
||||
if customer.telephone:
|
||||
phone_numbers.extend(
|
||||
[
|
||||
(
|
||||
tel.phone_number,
|
||||
PhoneTechType(tel.phone_tech_type)
|
||||
if tel.phone_tech_type
|
||||
else None,
|
||||
)
|
||||
for tel in customer.telephone
|
||||
]
|
||||
)
|
||||
|
||||
# Extract email info
|
||||
email_address = None
|
||||
email_newsletter = None
|
||||
if customer.email:
|
||||
email_address = customer.email.value
|
||||
if customer.email.remark:
|
||||
if "newsletter:yes" in customer.email.remark:
|
||||
email_newsletter = True
|
||||
elif "newsletter:no" in customer.email.remark:
|
||||
email_newsletter = False
|
||||
|
||||
# Extract address info
|
||||
address_line = None
|
||||
city_name = None
|
||||
postal_code = None
|
||||
country_code = None
|
||||
address_catalog = None
|
||||
|
||||
if customer.address:
|
||||
address_line = customer.address.address_line
|
||||
city_name = customer.address.city_name
|
||||
postal_code = customer.address.postal_code
|
||||
|
||||
if customer.address.country_name:
|
||||
country_code = customer.address.country_name.code
|
||||
|
||||
if customer.address.remark:
|
||||
if "catalog:yes" in customer.address.remark:
|
||||
address_catalog = True
|
||||
elif "catalog:no" in customer.address.remark:
|
||||
address_catalog = False
|
||||
|
||||
return CustomerData(
|
||||
given_name=customer.person_name.given_name,
|
||||
surname=customer.person_name.surname,
|
||||
name_prefix=customer.person_name.name_prefix,
|
||||
name_title=customer.person_name.name_title,
|
||||
phone_numbers=phone_numbers,
|
||||
email_address=email_address,
|
||||
email_newsletter=email_newsletter,
|
||||
address_line=address_line,
|
||||
city_name=city_name,
|
||||
postal_code=postal_code,
|
||||
country_code=country_code,
|
||||
address_catalog=address_catalog,
|
||||
gender=customer.gender,
|
||||
birth_date=customer.birth_date,
|
||||
language=customer.language,
|
||||
)
|
||||
|
||||
|
||||
class HotelReservationIdFactory:
|
||||
"""Factory class to create HotelReservationId instances for both OtaHotelResNotifRq and OtaResRetrieveRs."""
|
||||
|
||||
@staticmethod
|
||||
def create_notif_hotel_reservation_id(
|
||||
data: HotelReservationIdData,
|
||||
) -> NotifHotelReservationId:
|
||||
"""Create a HotelReservationId for OtaHotelResNotifRq."""
|
||||
return HotelReservationIdFactory._create_hotel_reservation_id(
|
||||
NotifHotelReservationId, data
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create_retrieve_hotel_reservation_id(
|
||||
data: HotelReservationIdData,
|
||||
) -> RetrieveHotelReservationId:
|
||||
"""Create a HotelReservationId for OtaResRetrieveRs."""
|
||||
return HotelReservationIdFactory._create_hotel_reservation_id(
|
||||
RetrieveHotelReservationId, data
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _create_hotel_reservation_id(
|
||||
hotel_reservation_id_class: type, data: HotelReservationIdData
|
||||
) -> Any:
|
||||
"""Create a hotel reservation id of the specified type."""
|
||||
return hotel_reservation_id_class(
|
||||
res_id_type=data.res_id_type,
|
||||
res_id_value=data.res_id_value,
|
||||
res_id_source=data.res_id_source,
|
||||
res_id_source_context=data.res_id_source_context,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_notif_hotel_reservation_id(
|
||||
hotel_reservation_id: NotifHotelReservationId,
|
||||
) -> HotelReservationIdData:
|
||||
"""Convert a NotifHotelReservationId back to HotelReservationIdData."""
|
||||
return HotelReservationIdFactory._hotel_reservation_id_to_data(
|
||||
hotel_reservation_id
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_retrieve_hotel_reservation_id(
|
||||
hotel_reservation_id: RetrieveHotelReservationId,
|
||||
) -> HotelReservationIdData:
|
||||
"""Convert a RetrieveHotelReservationId back to HotelReservationIdData."""
|
||||
return HotelReservationIdFactory._hotel_reservation_id_to_data(
|
||||
hotel_reservation_id
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _hotel_reservation_id_to_data(
|
||||
hotel_reservation_id: Any,
|
||||
) -> HotelReservationIdData:
|
||||
"""Internal method to convert any hotel reservation id type to HotelReservationIdData."""
|
||||
return HotelReservationIdData(
|
||||
res_id_type=hotel_reservation_id.res_id_type,
|
||||
res_id_value=hotel_reservation_id.res_id_value,
|
||||
res_id_source=hotel_reservation_id.res_id_source,
|
||||
res_id_source_context=hotel_reservation_id.res_id_source_context,
|
||||
)
|
||||
|
||||
|
||||
class CommentFactory:
|
||||
"""Factory class to create Comment instances for both OtaHotelResNotifRq and OtaResRetrieveRs."""
|
||||
|
||||
@staticmethod
|
||||
def create_notif_comments(data: CommentsData) -> NotifComments:
|
||||
"""Create Comments for OtaHotelResNotifRq."""
|
||||
return CommentFactory._create_comments(NotifComments, NotifComment, data)
|
||||
|
||||
@staticmethod
|
||||
def create_retrieve_comments(data: CommentsData) -> RetrieveComments:
|
||||
"""Create Comments for OtaResRetrieveRs."""
|
||||
return CommentFactory._create_comments(RetrieveComments, RetrieveComment, data)
|
||||
|
||||
@staticmethod
|
||||
def _create_comments(
|
||||
comments_class: type[RetrieveComments] | type[NotifComments],
|
||||
comment_class: type[RetrieveComment] | type[NotifComment],
|
||||
data: CommentsData,
|
||||
) -> Any:
|
||||
"""Internal method to create comments of the specified type."""
|
||||
comments_list = []
|
||||
for comment_data in data.comments:
|
||||
# Create list items
|
||||
list_items = []
|
||||
for item_data in comment_data.list_items:
|
||||
_LOGGER.debug(
|
||||
"Creating list item: value=%s, list_item=%s, language=%s",
|
||||
item_data.value,
|
||||
item_data.list_item,
|
||||
item_data.language,
|
||||
)
|
||||
|
||||
list_item = comment_class.ListItem(
|
||||
value=item_data.value,
|
||||
list_item=item_data.list_item,
|
||||
language=item_data.language,
|
||||
)
|
||||
list_items.append(list_item)
|
||||
|
||||
# Create comment
|
||||
comment = comment_class(
|
||||
name=comment_data.name, text=comment_data.text, list_item=list_items
|
||||
)
|
||||
comments_list.append(comment)
|
||||
|
||||
# Create comments container
|
||||
return comments_class(comment=comments_list)
|
||||
|
||||
@staticmethod
|
||||
def from_notif_comments(comments: NotifComments) -> CommentsData:
|
||||
"""Convert NotifComments back to CommentsData."""
|
||||
return CommentFactory._comments_to_data(comments)
|
||||
|
||||
@staticmethod
|
||||
def from_retrieve_comments(comments: RetrieveComments) -> CommentsData:
|
||||
"""Convert RetrieveComments back to CommentsData."""
|
||||
return CommentFactory._comments_to_data(comments)
|
||||
|
||||
@staticmethod
|
||||
def _comments_to_data(comments: Any) -> CommentsData:
|
||||
"""Internal method to convert any comments type to CommentsData."""
|
||||
comments_data_list = []
|
||||
for comment in comments.comment:
|
||||
# Extract list items
|
||||
list_items_data = []
|
||||
if comment.list_item:
|
||||
for list_item in comment.list_item:
|
||||
list_items_data.append(
|
||||
CommentListItemData(
|
||||
value=list_item.value,
|
||||
list_item=list_item.list_item,
|
||||
language=list_item.language,
|
||||
)
|
||||
)
|
||||
|
||||
comments_data_list.append(comment)
|
||||
|
||||
return CommentsData(comments=comments_data_list)
|
||||
|
||||
|
||||
# Define type aliases for ResGuests types
|
||||
NotifResGuests = OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGuests
|
||||
RetrieveResGuests = OtaResRetrieveRs.ReservationsList.HotelReservation.ResGuests
|
||||
|
||||
|
||||
class ResGuestFactory:
|
||||
"""Factory class to create complete ResGuests structures with a primary customer."""
|
||||
|
||||
@staticmethod
|
||||
def create_notif_res_guests(customer_data: CustomerData) -> NotifResGuests:
|
||||
"""Create a complete ResGuests structure for OtaHotelResNotifRq with primary customer."""
|
||||
return ResGuestFactory._create_res_guests(
|
||||
NotifResGuests, NotifCustomer, customer_data
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create_retrieve_res_guests(customer_data: CustomerData) -> RetrieveResGuests:
|
||||
"""Create a complete ResGuests structure for OtaResRetrieveRs with primary customer."""
|
||||
return ResGuestFactory._create_res_guests(
|
||||
RetrieveResGuests, RetrieveCustomer, customer_data
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _create_res_guests(
|
||||
res_guests_class: type[RetrieveResGuests] | type[NotifResGuests],
|
||||
customer_class: type[NotifCustomer | RetrieveCustomer],
|
||||
customer_data: CustomerData,
|
||||
) -> Any:
|
||||
"""Create the complete ResGuests structure."""
|
||||
# Create the customer using the existing CustomerFactory
|
||||
customer = CustomerFactory._create_customer(customer_class, customer_data)
|
||||
|
||||
# Create Profile with the customer
|
||||
profile = res_guests_class.ResGuest.Profiles.ProfileInfo.Profile(
|
||||
customer=customer
|
||||
)
|
||||
|
||||
# Create ProfileInfo with the profile
|
||||
profile_info = res_guests_class.ResGuest.Profiles.ProfileInfo(profile=profile)
|
||||
|
||||
# Create Profiles with the profile_info
|
||||
profiles = res_guests_class.ResGuest.Profiles(profile_info=profile_info)
|
||||
|
||||
# Create ResGuest with the profiles
|
||||
res_guest = res_guests_class.ResGuest(profiles=profiles)
|
||||
|
||||
# Create ResGuests with the res_guest
|
||||
return res_guests_class(res_guest=res_guest)
|
||||
|
||||
@staticmethod
|
||||
def extract_primary_customer(
|
||||
res_guests: NotifResGuests | RetrieveResGuests,
|
||||
) -> CustomerData:
|
||||
"""Extract the primary customer data from a ResGuests structure."""
|
||||
# Navigate down the nested structure to get the customer
|
||||
customer = res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
|
||||
# Use the existing CustomerFactory conversion method
|
||||
if isinstance(res_guests, NotifResGuests):
|
||||
return CustomerFactory.from_notif_customer(customer)
|
||||
return CustomerFactory.from_retrieve_customer(customer)
|
||||
|
||||
|
||||
class AlpineBitsFactory:
|
||||
"""Unified factory class for creating AlpineBits objects with a simple interface."""
|
||||
|
||||
@staticmethod
|
||||
def create(
|
||||
data: CustomerData | HotelReservationIdData | CommentsData,
|
||||
message_type: OtaMessageType,
|
||||
) -> Any:
|
||||
"""Create an AlpineBits object based on the data type and message type.
|
||||
|
||||
Args:
|
||||
data: The data object (CustomerData, HotelReservationIdData, CommentsData, etc.)
|
||||
message_type: Whether to create for NOTIF or RETRIEVE message types
|
||||
|
||||
Returns:
|
||||
The appropriate AlpineBits object based on the data type and message type
|
||||
|
||||
"""
|
||||
if isinstance(data, CustomerData):
|
||||
if message_type == OtaMessageType.NOTIF:
|
||||
return CustomerFactory.create_notif_customer(data)
|
||||
return CustomerFactory.create_retrieve_customer(data)
|
||||
|
||||
if isinstance(data, HotelReservationIdData):
|
||||
if message_type == OtaMessageType.NOTIF:
|
||||
return HotelReservationIdFactory.create_notif_hotel_reservation_id(data)
|
||||
return HotelReservationIdFactory.create_retrieve_hotel_reservation_id(data)
|
||||
|
||||
if isinstance(data, CommentsData):
|
||||
if message_type == OtaMessageType.NOTIF:
|
||||
return CommentFactory.create_notif_comments(data)
|
||||
return CommentFactory.create_retrieve_comments(data)
|
||||
|
||||
raise ValueError(f"Unsupported data type: {type(data)}")
|
||||
|
||||
@staticmethod
|
||||
def create_res_guests(
|
||||
customer_data: CustomerData, message_type: OtaMessageType
|
||||
) -> NotifResGuests | RetrieveResGuests:
|
||||
"""Create a complete ResGuests structure with a primary customer.
|
||||
|
||||
Args:
|
||||
customer_data: The customer data
|
||||
message_type: Whether to create for NOTIF or RETRIEVE message types
|
||||
|
||||
Returns:
|
||||
The appropriate ResGuests object
|
||||
|
||||
"""
|
||||
if message_type == OtaMessageType.NOTIF:
|
||||
return ResGuestFactory.create_notif_res_guests(customer_data)
|
||||
return ResGuestFactory.create_retrieve_res_guests(customer_data)
|
||||
|
||||
@staticmethod
|
||||
def extract_data(
|
||||
obj: Any,
|
||||
) -> CustomerData | HotelReservationIdData | CommentsData:
|
||||
"""Extract data from an AlpineBits object back to a simple data class.
|
||||
|
||||
Args:
|
||||
obj: The AlpineBits object to extract data from
|
||||
|
||||
Returns:
|
||||
The appropriate data object
|
||||
|
||||
"""
|
||||
# Check if it's a Customer object
|
||||
if hasattr(obj, "person_name") and hasattr(obj.person_name, "given_name"):
|
||||
if isinstance(obj, NotifCustomer):
|
||||
return CustomerFactory.from_notif_customer(obj)
|
||||
if isinstance(obj, RetrieveCustomer):
|
||||
return CustomerFactory.from_retrieve_customer(obj)
|
||||
|
||||
# Check if it's a HotelReservationId object
|
||||
elif hasattr(obj, "res_id_type"):
|
||||
if isinstance(obj, NotifHotelReservationId):
|
||||
return HotelReservationIdFactory.from_notif_hotel_reservation_id(obj)
|
||||
if isinstance(obj, RetrieveHotelReservationId):
|
||||
return HotelReservationIdFactory.from_retrieve_hotel_reservation_id(obj)
|
||||
|
||||
# Check if it's a Comments object
|
||||
elif hasattr(obj, "comment"):
|
||||
if isinstance(obj, NotifComments):
|
||||
return CommentFactory.from_notif_comments(obj)
|
||||
if isinstance(obj, RetrieveComments):
|
||||
return CommentFactory.from_retrieve_comments(obj)
|
||||
|
||||
# Check if it's a ResGuests object
|
||||
elif hasattr(obj, "res_guest"):
|
||||
return ResGuestFactory.extract_primary_customer(obj)
|
||||
|
||||
else:
|
||||
raise ValueError(f"Unsupported object type: {type(obj)}")
|
||||
return None
|
||||
|
||||
|
||||
def create_res_retrieve_response(
|
||||
list: list[tuple[Reservation, Customer]], config: dict[str, Any]
|
||||
) -> OtaResRetrieveRs:
|
||||
"""Create RetrievedReservation XML from database entries."""
|
||||
return _create_xml_from_db(list, OtaMessageType.RETRIEVE, config)
|
||||
|
||||
|
||||
def create_res_notif_push_message(
|
||||
list: tuple[Reservation, Customer], config: dict[str, Any]
|
||||
):
|
||||
"""Create Reservation Notification XML from database entries."""
|
||||
return _create_xml_from_db(list, OtaMessageType.NOTIF, config)
|
||||
|
||||
|
||||
def _process_single_reservation(
|
||||
reservation: Reservation,
|
||||
customer: Customer,
|
||||
message_type: OtaMessageType,
|
||||
config: dict[str, Any],
|
||||
):
|
||||
phone_numbers = (
|
||||
[(customer.phone, PhoneTechType.MOBILE)] if customer.phone is not None else []
|
||||
)
|
||||
|
||||
customer_data = CustomerData(
|
||||
given_name=customer.given_name,
|
||||
surname=customer.surname,
|
||||
name_prefix=customer.name_prefix,
|
||||
name_title=customer.name_title,
|
||||
phone_numbers=phone_numbers,
|
||||
email_address=customer.email_address,
|
||||
email_newsletter=customer.email_newsletter,
|
||||
address_line=customer.address_line,
|
||||
city_name=customer.city_name,
|
||||
postal_code=customer.postal_code,
|
||||
country_code=customer.country_code,
|
||||
address_catalog=customer.address_catalog,
|
||||
gender=customer.gender,
|
||||
birth_date=customer.birth_date,
|
||||
language=customer.language,
|
||||
)
|
||||
alpine_bits_factory = AlpineBitsFactory()
|
||||
res_guests = alpine_bits_factory.create_res_guests(customer_data, message_type)
|
||||
|
||||
# Guest counts
|
||||
children_ages = [int(a) for a in reservation.children_ages.split(",") if a]
|
||||
guest_counts = GuestCountsFactory.create_guest_counts(
|
||||
reservation.num_adults, children_ages, message_type
|
||||
)
|
||||
|
||||
if message_type == OtaMessageType.NOTIF:
|
||||
UniqueId = NotifUniqueId
|
||||
RoomStays = NotifRoomStays
|
||||
HotelReservation = NotifHotelReservation
|
||||
Profile = OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGlobalInfo.Profiles.ProfileInfo.Profile
|
||||
elif message_type == OtaMessageType.RETRIEVE:
|
||||
UniqueId = RetrieveUniqueId
|
||||
RoomStays = RetrieveRoomStays
|
||||
HotelReservation = RetrieveHotelReservation
|
||||
Profile = OtaResRetrieveRs.ReservationsList.HotelReservation.ResGlobalInfo.Profiles.ProfileInfo.Profile
|
||||
else:
|
||||
raise ValueError("Unsupported message type: %s", message_type.value)
|
||||
|
||||
unique_id_str = reservation.md5_unique_id
|
||||
|
||||
# UniqueID
|
||||
unique_id = UniqueId(type_value=UniqueIdType2.VALUE_14, id=unique_id_str)
|
||||
|
||||
# TimeSpan
|
||||
time_span = RoomStays.RoomStay.TimeSpan(
|
||||
start=reservation.start_date.isoformat() if reservation.start_date else None,
|
||||
end=reservation.end_date.isoformat() if reservation.end_date else None,
|
||||
)
|
||||
room_stay = RoomStays.RoomStay(
|
||||
time_span=time_span,
|
||||
guest_counts=guest_counts,
|
||||
)
|
||||
room_stays = RoomStays(
|
||||
room_stay=[room_stay],
|
||||
)
|
||||
|
||||
res_id_source = "website"
|
||||
klick_id = None
|
||||
|
||||
if reservation.fbclid != "":
|
||||
klick_id = str(reservation.fbclid)
|
||||
res_id_source = "meta"
|
||||
elif reservation.gclid != "":
|
||||
klick_id = str(reservation.gclid)
|
||||
res_id_source = "google"
|
||||
|
||||
# Get utm_medium if available, otherwise use source
|
||||
if reservation.utm_medium is not None and str(reservation.utm_medium) != "":
|
||||
res_id_source = str(reservation.utm_medium)
|
||||
|
||||
# Use Pydantic model for automatic validation and truncation
|
||||
# It will automatically:
|
||||
# - Trim whitespace
|
||||
# - Truncate to 64 characters if needed
|
||||
# - Convert empty strings to None
|
||||
|
||||
res_id_source_context = config["server"]["res_id_source_context"]
|
||||
|
||||
hotel_res_id_data = HotelReservationIdData(
|
||||
res_id_type=RESERVATION_ID_TYPE,
|
||||
res_id_value=klick_id,
|
||||
res_id_source=res_id_source,
|
||||
res_id_source_context=res_id_source_context,
|
||||
)
|
||||
|
||||
hotel_res_id = alpine_bits_factory.create(hotel_res_id_data, message_type)
|
||||
hotel_res_ids = HotelReservation.ResGlobalInfo.HotelReservationIds(
|
||||
hotel_reservation_id=[hotel_res_id]
|
||||
)
|
||||
|
||||
if reservation.hotel_code is None:
|
||||
raise ValueError("Reservation hotel_code is None")
|
||||
hotel_code = str(reservation.hotel_code)
|
||||
hotel_name = None if reservation.hotel_name is None else str(reservation.hotel_name)
|
||||
|
||||
basic_property_info = HotelReservation.ResGlobalInfo.BasicPropertyInfo(
|
||||
hotel_code=hotel_code,
|
||||
hotel_name=hotel_name,
|
||||
)
|
||||
# Comments
|
||||
|
||||
offer_comment = None
|
||||
if reservation.offer is not None:
|
||||
offer_comment = CommentData(
|
||||
name=CommentName2.ADDITIONAL_INFO,
|
||||
text="Angebot/Offerta: " + reservation.offer,
|
||||
# list_items=[
|
||||
# CommentListItemData(
|
||||
# value=reservation.offer,
|
||||
# language=customer.language,
|
||||
# list_item="1",
|
||||
# )
|
||||
# ],
|
||||
)
|
||||
comment = None
|
||||
if reservation.user_comment:
|
||||
comment = CommentData(
|
||||
name=CommentName2.CUSTOMER_COMMENT,
|
||||
text=reservation.user_comment,
|
||||
# list_items=[
|
||||
# CommentListItemData(
|
||||
# value="Landing page comment",
|
||||
# language=customer.language,
|
||||
# list_item="1",
|
||||
# )
|
||||
# ],
|
||||
)
|
||||
comments = [offer_comment, comment]
|
||||
|
||||
# filter out None comments
|
||||
comments = [c for c in comments if c is not None]
|
||||
|
||||
comments_xml = None
|
||||
if comments:
|
||||
for c in comments:
|
||||
_LOGGER.debug(
|
||||
"Creating comment: name=%s, text=%s, list_items=%s",
|
||||
c.name,
|
||||
c.text,
|
||||
len(c.list_items),
|
||||
)
|
||||
|
||||
comments_data = CommentsData(comments=comments)
|
||||
comments_xml = alpine_bits_factory.create(comments_data, message_type)
|
||||
|
||||
company_name_value = config["server"]["companyname"]
|
||||
company_code = config["server"]["code"]
|
||||
codecontext = config["server"]["codecontext"]
|
||||
|
||||
company_name = Profile.CompanyInfo.CompanyName(
|
||||
value=company_name_value, code=company_code, code_context=codecontext
|
||||
)
|
||||
|
||||
company_info = Profile.CompanyInfo(company_name=company_name)
|
||||
|
||||
profile = Profile(
|
||||
company_info=company_info, profile_type=ProfileProfileType.VALUE_4
|
||||
)
|
||||
|
||||
profile_info = HotelReservation.ResGlobalInfo.Profiles.ProfileInfo(profile=profile)
|
||||
|
||||
_LOGGER.info("Type of profile_info: %s", type(profile_info))
|
||||
|
||||
profiles = HotelReservation.ResGlobalInfo.Profiles(profile_info=profile_info)
|
||||
|
||||
res_global_info = HotelReservation.ResGlobalInfo(
|
||||
hotel_reservation_ids=hotel_res_ids,
|
||||
basic_property_info=basic_property_info,
|
||||
comments=comments_xml,
|
||||
profiles=profiles,
|
||||
)
|
||||
|
||||
return HotelReservation(
|
||||
create_date_time=reservation.created_at.replace(tzinfo=UTC).isoformat(),
|
||||
res_status=HotelReservationResStatus.REQUESTED,
|
||||
room_stay_reservation="true",
|
||||
unique_id=unique_id,
|
||||
room_stays=room_stays,
|
||||
res_guests=res_guests,
|
||||
res_global_info=res_global_info,
|
||||
)
|
||||
|
||||
|
||||
def _create_xml_from_db(
|
||||
entries: list[tuple[Reservation, Customer]] | tuple[Reservation, Customer],
|
||||
type: OtaMessageType,
|
||||
config: dict[str, Any],
|
||||
):
|
||||
"""Create RetrievedReservation XML from database entries.
|
||||
|
||||
list of pairs (Reservation, Customer)
|
||||
"""
|
||||
reservations_list = []
|
||||
|
||||
# if entries isn't a list wrap the element in a list
|
||||
|
||||
if not isinstance(entries, list):
|
||||
entries = [entries]
|
||||
|
||||
for reservation, customer in entries:
|
||||
_LOGGER.info(
|
||||
"Creating XML for reservation %s and customer %s",
|
||||
reservation.id,
|
||||
customer.id,
|
||||
)
|
||||
|
||||
try:
|
||||
hotel_reservation = _process_single_reservation(
|
||||
reservation, customer, type, config
|
||||
)
|
||||
|
||||
reservations_list.append(hotel_reservation)
|
||||
|
||||
except Exception:
|
||||
_LOGGER.exception(
|
||||
"Error creating XML for reservation %s and customer %s",
|
||||
reservation.unique_id,
|
||||
customer.given_name,
|
||||
)
|
||||
_LOGGER.debug(traceback.format_exc())
|
||||
|
||||
if type == OtaMessageType.NOTIF:
|
||||
res_list_obj = OtaHotelResNotifRq.HotelReservations(
|
||||
hotel_reservation=reservations_list
|
||||
)
|
||||
|
||||
ota_hotel_res_notif_rq = OtaHotelResNotifRq(
|
||||
version="7.000", hotel_reservations=res_list_obj
|
||||
)
|
||||
|
||||
try:
|
||||
ota_hotel_res_notif_rq.model_validate(ota_hotel_res_notif_rq.model_dump())
|
||||
except Exception:
|
||||
_LOGGER.exception("Validation error: ")
|
||||
raise
|
||||
|
||||
return ota_hotel_res_notif_rq
|
||||
if type == OtaMessageType.RETRIEVE:
|
||||
res_list_obj = OtaResRetrieveRs.ReservationsList(
|
||||
hotel_reservation=reservations_list
|
||||
)
|
||||
|
||||
ota_res_retrieve_rs = OtaResRetrieveRs(
|
||||
version="7.000", success="", reservations_list=res_list_obj
|
||||
)
|
||||
|
||||
try:
|
||||
ota_res_retrieve_rs.model_validate(ota_res_retrieve_rs.model_dump())
|
||||
except Exception as e:
|
||||
_LOGGER.exception(f"Validation error: {e}")
|
||||
raise
|
||||
|
||||
return ota_res_retrieve_rs
|
||||
|
||||
raise ValueError(f"Unsupported message type: {type}")
|
||||
@@ -1,178 +0,0 @@
|
||||
import xml.etree.ElementTree as ET
|
||||
from datetime import datetime, timezone
|
||||
from typing import List, Optional
|
||||
|
||||
|
||||
# TimeSpan class according to XSD: <TimeSpan Start="..." End="..." Duration="..." StartWindow="..." EndWindow="..."/>
|
||||
class TimeSpan:
|
||||
def __init__(
|
||||
self,
|
||||
start: str,
|
||||
end: str = None,
|
||||
duration: str = None,
|
||||
start_window: str = None,
|
||||
end_window: str = None,
|
||||
):
|
||||
self.start = start
|
||||
self.end = end
|
||||
self.duration = duration
|
||||
self.start_window = start_window
|
||||
self.end_window = end_window
|
||||
|
||||
def to_xml(self):
|
||||
attrib = {"Start": self.start}
|
||||
if self.end:
|
||||
attrib["End"] = self.end
|
||||
if self.duration:
|
||||
attrib["Duration"] = self.duration
|
||||
if self.start_window:
|
||||
attrib["StartWindow"] = self.start_window
|
||||
if self.end_window:
|
||||
attrib["EndWindow"] = self.end_window
|
||||
return ET.Element(_ns("TimeSpan"), attrib)
|
||||
|
||||
|
||||
NAMESPACE = "http://www.opentravel.org/OTA/2003/05"
|
||||
ET.register_namespace("", NAMESPACE)
|
||||
|
||||
|
||||
def _ns(tag):
|
||||
return f"{{{NAMESPACE}}}{tag}"
|
||||
|
||||
|
||||
class ResGuest:
|
||||
def __init__(
|
||||
self,
|
||||
given_name: str,
|
||||
surname: str,
|
||||
gender: Optional[str] = None,
|
||||
birth_date: Optional[str] = None,
|
||||
language: Optional[str] = None,
|
||||
name_prefix: Optional[str] = None,
|
||||
name_title: Optional[str] = None,
|
||||
email: Optional[str] = None,
|
||||
address: Optional[dict] = None,
|
||||
telephones: Optional[list] = None,
|
||||
):
|
||||
self.given_name = given_name
|
||||
self.surname = surname
|
||||
self.gender = gender
|
||||
self.birth_date = birth_date
|
||||
self.language = language
|
||||
self.name_prefix = name_prefix
|
||||
self.name_title = name_title
|
||||
self.email = email
|
||||
self.address = address or {}
|
||||
self.telephones = telephones or []
|
||||
|
||||
def to_xml(self):
|
||||
resguest_elem = ET.Element(_ns("ResGuest"))
|
||||
profiles_elem = ET.SubElement(resguest_elem, _ns("Profiles"))
|
||||
profileinfo_elem = ET.SubElement(profiles_elem, _ns("ProfileInfo"))
|
||||
profile_elem = ET.SubElement(profileinfo_elem, _ns("Profile"))
|
||||
customer_elem = ET.SubElement(profile_elem, _ns("Customer"))
|
||||
if self.gender:
|
||||
customer_elem.set("Gender", self.gender)
|
||||
if self.birth_date:
|
||||
customer_elem.set("BirthDate", self.birth_date)
|
||||
if self.language:
|
||||
customer_elem.set("Language", self.language)
|
||||
personname_elem = ET.SubElement(customer_elem, _ns("PersonName"))
|
||||
if self.name_prefix:
|
||||
ET.SubElement(personname_elem, _ns("NamePrefix")).text = self.name_prefix
|
||||
ET.SubElement(personname_elem, _ns("GivenName")).text = self.given_name
|
||||
ET.SubElement(personname_elem, _ns("Surname")).text = self.surname
|
||||
if self.name_title:
|
||||
ET.SubElement(personname_elem, _ns("NameTitle")).text = self.name_title
|
||||
for tel in self.telephones:
|
||||
tel_elem = ET.SubElement(customer_elem, _ns("Telephone"))
|
||||
for k, v in tel.items():
|
||||
tel_elem.set(k, v)
|
||||
if self.email:
|
||||
ET.SubElement(customer_elem, _ns("Email")).text = self.email
|
||||
if self.address:
|
||||
address_elem = ET.SubElement(customer_elem, _ns("Address"))
|
||||
for k, v in self.address.items():
|
||||
if k == "CountryName":
|
||||
country_elem = ET.SubElement(address_elem, _ns("CountryName"))
|
||||
if isinstance(v, dict):
|
||||
for ck, cv in v.items():
|
||||
country_elem.set(ck, cv)
|
||||
else:
|
||||
country_elem.text = v
|
||||
else:
|
||||
ET.SubElement(address_elem, _ns(k)).text = v
|
||||
return resguest_elem
|
||||
|
||||
def __str__(self):
|
||||
from lxml import etree
|
||||
|
||||
elem = self.to_xml()
|
||||
xml_bytes = ET.tostring(elem, encoding="utf-8")
|
||||
parser = etree.XMLParser(remove_blank_text=True)
|
||||
lxml_elem = etree.fromstring(xml_bytes, parser)
|
||||
return etree.tostring(lxml_elem, pretty_print=True, encoding="unicode")
|
||||
|
||||
|
||||
class RoomStay:
|
||||
def __init__(self, room_type: str, timespan: TimeSpan, guests: List[ResGuest]):
|
||||
self.room_type = room_type
|
||||
self.timespan = timespan
|
||||
self.guests = guests
|
||||
|
||||
def to_xml(self):
|
||||
roomstay_elem = ET.Element(_ns("RoomStay"))
|
||||
ET.SubElement(roomstay_elem, _ns("RoomType")).set(
|
||||
"RoomTypeCode", self.room_type
|
||||
)
|
||||
roomstay_elem.append(self.timespan.to_xml())
|
||||
guests_elem = ET.SubElement(roomstay_elem, _ns("Guests"))
|
||||
for guest in self.guests:
|
||||
guests_elem.append(guest.to_xml())
|
||||
return roomstay_elem
|
||||
|
||||
def __str__(self):
|
||||
from lxml import etree
|
||||
|
||||
elem = self.to_xml()
|
||||
xml_bytes = ET.tostring(elem, encoding="utf-8")
|
||||
parser = etree.XMLParser(remove_blank_text=True)
|
||||
lxml_elem = etree.fromstring(xml_bytes, parser)
|
||||
return etree.tostring(lxml_elem, pretty_print=True, encoding="unicode")
|
||||
|
||||
|
||||
class Reservation:
|
||||
def __init__(
|
||||
self,
|
||||
reservation_id: str,
|
||||
hotel_code: str,
|
||||
roomstays: List[RoomStay],
|
||||
create_time: Optional[str] = None,
|
||||
):
|
||||
self.reservation_id = reservation_id
|
||||
self.hotel_code = hotel_code
|
||||
self.roomstays = roomstays
|
||||
self.create_time = create_time or datetime.now(timezone.utc).isoformat()
|
||||
|
||||
def to_xml(self):
|
||||
res_elem = ET.Element(_ns("HotelReservation"))
|
||||
uniqueid_elem = ET.SubElement(res_elem, _ns("UniqueID"))
|
||||
uniqueid_elem.set("Type", "14")
|
||||
uniqueid_elem.set("ID", self.reservation_id)
|
||||
hotel_elem = ET.SubElement(res_elem, _ns("Hotel"))
|
||||
hotel_elem.set("HotelCode", self.hotel_code)
|
||||
roomstays_elem = ET.SubElement(res_elem, _ns("RoomStays"))
|
||||
for rs in self.roomstays:
|
||||
roomstays_elem.append(rs.to_xml())
|
||||
res_elem.set("CreateDateTime", self.create_time)
|
||||
return res_elem
|
||||
|
||||
def to_xml_string(self):
|
||||
root = ET.Element(
|
||||
_ns("OTA_ResRetrieveRS"),
|
||||
{"Version": "2024-10", "TimeStamp": datetime.now(timezone.utc).isoformat()},
|
||||
)
|
||||
success_elem = ET.SubElement(root, _ns("Success"))
|
||||
reservations_list = ET.SubElement(root, _ns("ReservationsList"))
|
||||
reservations_list.append(self.to_xml())
|
||||
return ET.tostring(root, encoding="utf-8", xml_declaration=True).decode("utf-8")
|
||||
File diff suppressed because it is too large
Load Diff
1036
src/alpine_bits_python/api.py
Normal file
1036
src/alpine_bits_python/api.py
Normal file
File diff suppressed because it is too large
Load Diff
114
src/alpine_bits_python/auth.py
Normal file
114
src/alpine_bits_python/auth.py
Normal file
@@ -0,0 +1,114 @@
|
||||
import hashlib
|
||||
import hmac
|
||||
import os
|
||||
import secrets
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from fastapi import HTTPException, Security, status
|
||||
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
from .logging_config import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
# Security scheme
|
||||
security = HTTPBearer()
|
||||
|
||||
# API Keys - In production, store these in environment variables or a secure database
|
||||
API_KEYS = {
|
||||
# Example API keys - replace with your own secure keys
|
||||
"wix-webhook-key": "sk_live_your_secure_api_key_here",
|
||||
"admin-key": "sk_admin_your_admin_key_here",
|
||||
}
|
||||
|
||||
# Load API keys from environment if available
|
||||
if os.getenv("WIX_API_KEY"):
|
||||
API_KEYS["wix-webhook-key"] = os.getenv("WIX_API_KEY")
|
||||
if os.getenv("ADMIN_API_KEY"):
|
||||
API_KEYS["admin-key"] = os.getenv("ADMIN_API_KEY")
|
||||
|
||||
|
||||
def generate_unique_id() -> str:
|
||||
"""Generate a unique ID with max length 32 characters."""
|
||||
return secrets.token_urlsafe(26)[:32] # 26 bytes -> 32 chars in base64url
|
||||
|
||||
|
||||
def generate_api_key() -> str:
|
||||
"""Generate a secure API key."""
|
||||
return f"sk_live_{secrets.token_urlsafe(32)}"
|
||||
|
||||
|
||||
def validate_api_key(
|
||||
credentials: HTTPAuthorizationCredentials = Security(security),
|
||||
) -> str:
|
||||
"""Validate API key from Authorization header.
|
||||
|
||||
Expected format: Authorization: Bearer your_api_key_here
|
||||
"""
|
||||
token = credentials.credentials
|
||||
|
||||
# Check if the token is in our valid API keys
|
||||
for key_name, valid_key in API_KEYS.items():
|
||||
if secrets.compare_digest(token, valid_key):
|
||||
logger.info(f"Valid API key used: {key_name}")
|
||||
return key_name
|
||||
|
||||
logger.warning(f"Invalid API key attempted: {token[:10]}...")
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Invalid API key",
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
|
||||
|
||||
def validate_wix_signature(payload: bytes, signature: str, secret: str) -> bool:
|
||||
"""Validate Wix webhook signature for additional security.
|
||||
|
||||
Wix signs their webhooks with HMAC-SHA256.
|
||||
"""
|
||||
if not signature or not secret:
|
||||
return False
|
||||
|
||||
try:
|
||||
# Remove 'sha256=' prefix if present
|
||||
signature = signature.removeprefix("sha256=")
|
||||
|
||||
# Calculate expected signature
|
||||
expected_signature = hmac.new(
|
||||
secret.encode("utf-8"), payload, hashlib.sha256
|
||||
).hexdigest()
|
||||
|
||||
# Compare signatures securely
|
||||
return secrets.compare_digest(signature, expected_signature)
|
||||
except Exception as e:
|
||||
logger.exception(f"Error validating signature: {e}")
|
||||
return False
|
||||
|
||||
|
||||
class APIKeyAuth:
|
||||
"""Simple API key authentication class."""
|
||||
|
||||
def __init__(self, api_keys: dict):
|
||||
self.api_keys = api_keys
|
||||
|
||||
def authenticate(self, api_key: str) -> str | None:
|
||||
"""Authenticate an API key and return the key name if valid."""
|
||||
for key_name, valid_key in self.api_keys.items():
|
||||
if secrets.compare_digest(api_key, valid_key):
|
||||
return key_name
|
||||
return None
|
||||
|
||||
def add_key(self, name: str, key: str):
|
||||
"""Add a new API key."""
|
||||
self.api_keys[name] = key
|
||||
|
||||
def remove_key(self, name: str):
|
||||
"""Remove an API key."""
|
||||
if name in self.api_keys:
|
||||
del self.api_keys[name]
|
||||
|
||||
|
||||
# Initialize auth system
|
||||
auth_system = APIKeyAuth(API_KEYS)
|
||||
149
src/alpine_bits_python/config_loader.py
Normal file
149
src/alpine_bits_python/config_loader.py
Normal file
@@ -0,0 +1,149 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from annotatedyaml.loader import Secrets
|
||||
from annotatedyaml.loader import load_yaml as load_annotated_yaml
|
||||
from voluptuous import (
|
||||
PREVENT_EXTRA,
|
||||
All,
|
||||
Length,
|
||||
MultipleInvalid,
|
||||
Optional,
|
||||
Required,
|
||||
Schema,
|
||||
)
|
||||
|
||||
from alpine_bits_python.const import (
|
||||
CONF_ALPINE_BITS_AUTH,
|
||||
CONF_DATABASE,
|
||||
CONF_HOTEL_ID,
|
||||
CONF_HOTEL_NAME,
|
||||
CONF_LOGGING,
|
||||
CONF_LOGGING_FILE,
|
||||
CONF_LOGGING_LEVEL,
|
||||
CONF_PASSWORD,
|
||||
CONF_PUSH_ENDPOINT,
|
||||
CONF_PUSH_TOKEN,
|
||||
CONF_PUSH_URL,
|
||||
CONF_PUSH_USERNAME,
|
||||
CONF_SERVER,
|
||||
CONF_SERVER_CODE,
|
||||
CONF_SERVER_CODECONTEXT,
|
||||
CONF_SERVER_COMPANYNAME,
|
||||
CONF_SERVER_RES_ID_SOURCE_CONTEXT,
|
||||
CONF_USERNAME,
|
||||
ENV_ALPINE_BITS_CONFIG_PATH,
|
||||
)
|
||||
|
||||
# --- Voluptuous schemas ---
|
||||
database_schema = Schema({Required("url"): str}, extra=PREVENT_EXTRA)
|
||||
|
||||
|
||||
logger_schema = Schema(
|
||||
{
|
||||
Required(CONF_LOGGING_LEVEL, default="INFO"): str,
|
||||
Optional(CONF_LOGGING_FILE): str, # If not provided, log to console
|
||||
},
|
||||
extra=PREVENT_EXTRA,
|
||||
)
|
||||
|
||||
|
||||
def ensure_string(value):
|
||||
"""Ensure the value is a string."""
|
||||
if isinstance(value, str):
|
||||
return value
|
||||
return str(value)
|
||||
|
||||
|
||||
server_info = Schema(
|
||||
{
|
||||
Required(CONF_SERVER_CODECONTEXT, default="ADVERTISING"): ensure_string,
|
||||
Required(CONF_SERVER_CODE, default="70597314"): ensure_string,
|
||||
Required(CONF_SERVER_COMPANYNAME, default="99tales Gmbh"): ensure_string,
|
||||
Required(CONF_SERVER_RES_ID_SOURCE_CONTEXT, default="99tales"): ensure_string,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
hotel_auth_schema = Schema(
|
||||
{
|
||||
Required(CONF_HOTEL_ID): ensure_string,
|
||||
Required(CONF_HOTEL_NAME): str,
|
||||
Required(CONF_USERNAME): str,
|
||||
Required(CONF_PASSWORD): str,
|
||||
Optional(CONF_PUSH_ENDPOINT): {
|
||||
Required(CONF_PUSH_URL): str,
|
||||
Required(CONF_PUSH_TOKEN): str,
|
||||
Optional(CONF_PUSH_USERNAME): str,
|
||||
},
|
||||
},
|
||||
extra=PREVENT_EXTRA,
|
||||
)
|
||||
|
||||
basic_auth_schema = Schema(All([hotel_auth_schema], Length(min=1)))
|
||||
|
||||
config_schema = Schema(
|
||||
{
|
||||
Required(CONF_DATABASE): database_schema,
|
||||
Required(CONF_ALPINE_BITS_AUTH): basic_auth_schema,
|
||||
Required(CONF_SERVER): server_info,
|
||||
Required(CONF_LOGGING): logger_schema,
|
||||
},
|
||||
extra=PREVENT_EXTRA,
|
||||
)
|
||||
|
||||
DEFAULT_CONFIG_FILE = "config.yaml"
|
||||
|
||||
|
||||
class Config:
|
||||
def __init__(
|
||||
self,
|
||||
config_folder: str | Path | None = None,
|
||||
config_name: str = DEFAULT_CONFIG_FILE,
|
||||
testing_mode: bool = False,
|
||||
):
|
||||
if config_folder is None:
|
||||
config_folder = os.environ.get(ENV_ALPINE_BITS_CONFIG_PATH)
|
||||
if not config_folder:
|
||||
config_folder = Path(__file__).parent.joinpath("../../config").resolve()
|
||||
if isinstance(config_folder, str):
|
||||
config_folder = Path(config_folder)
|
||||
self.config_folder = config_folder
|
||||
self.config_path = config_folder / config_name
|
||||
self.secrets = Secrets(config_folder)
|
||||
self.testing_mode = testing_mode
|
||||
self._load_config()
|
||||
|
||||
def _load_config(self):
|
||||
stuff = load_annotated_yaml(self.config_path, secrets=self.secrets)
|
||||
try:
|
||||
validated = config_schema(stuff)
|
||||
except MultipleInvalid as e:
|
||||
raise ValueError(f"Config validation error: {e}")
|
||||
self.database = validated["database"]
|
||||
self.basic_auth = validated["alpine_bits_auth"]
|
||||
self.config = validated
|
||||
|
||||
def get(self, key, default=None):
|
||||
return self.config.get(key, default)
|
||||
|
||||
@property
|
||||
def db_url(self) -> str:
|
||||
return self.database["url"]
|
||||
|
||||
@property
|
||||
def hotel_id(self) -> str:
|
||||
return self.basic_auth["hotel_id"]
|
||||
|
||||
@property
|
||||
def hotel_name(self) -> str:
|
||||
return self.basic_auth["hotel_name"]
|
||||
|
||||
@property
|
||||
def users(self) -> list[dict[str, str]]:
|
||||
return self.basic_auth["users"]
|
||||
|
||||
|
||||
# For backward compatibility
|
||||
def load_config():
|
||||
return Config().config
|
||||
34
src/alpine_bits_python/const.py
Normal file
34
src/alpine_bits_python/const.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from typing import Final
|
||||
|
||||
RESERVATION_ID_TYPE: str = (
|
||||
"13" # Default reservation ID type for Reservation. 14 would be cancellation
|
||||
)
|
||||
|
||||
|
||||
CONF_LOGGING: Final[str] = "logger"
|
||||
|
||||
CONF_LOGGING_LEVEL: Final[str] = "level"
|
||||
CONF_LOGGING_FILE: Final[str] = "file"
|
||||
|
||||
|
||||
CONF_DATABASE: Final[str] = "database"
|
||||
|
||||
|
||||
CONF_SERVER: Final[str] = "server"
|
||||
CONF_SERVER_CODECONTEXT: Final[str] = "codecontext"
|
||||
CONF_SERVER_CODE: Final[str] = "code"
|
||||
CONF_SERVER_COMPANYNAME: Final[str] = "companyname"
|
||||
CONF_SERVER_RES_ID_SOURCE_CONTEXT: Final[str] = "res_id_source_context"
|
||||
|
||||
|
||||
CONF_ALPINE_BITS_AUTH: Final[str] = "alpine_bits_auth"
|
||||
CONF_HOTEL_ID: Final[str] = "hotel_id"
|
||||
CONF_HOTEL_NAME: Final[str] = "hotel_name"
|
||||
CONF_USERNAME: Final[str] = "username"
|
||||
CONF_PASSWORD: Final[str] = "password"
|
||||
CONF_PUSH_ENDPOINT: Final[str] = "push_endpoint"
|
||||
CONF_PUSH_URL: Final[str] = "url"
|
||||
CONF_PUSH_TOKEN: Final[str] = "token"
|
||||
CONF_PUSH_USERNAME: Final[str] = "username"
|
||||
|
||||
ENV_ALPINE_BITS_CONFIG_PATH: Final[str] = "ALPINE_BITS_CONFIG_DIR"
|
||||
79
src/alpine_bits_python/db.py
Normal file
79
src/alpine_bits_python/db.py
Normal file
@@ -0,0 +1,79 @@
|
||||
import os
|
||||
|
||||
from sqlalchemy import Boolean, Column, Date, DateTime, ForeignKey, Integer, String
|
||||
from sqlalchemy.orm import declarative_base, relationship
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
# Async SQLAlchemy setup
|
||||
def get_database_url(config=None):
|
||||
db_url = None
|
||||
if config and "database" in config and "url" in config["database"]:
|
||||
db_url = config["database"]["url"]
|
||||
if not db_url:
|
||||
db_url = os.environ.get("DATABASE_URL")
|
||||
if not db_url:
|
||||
db_url = "sqlite+aiosqlite:///alpinebits.db"
|
||||
return db_url
|
||||
|
||||
|
||||
class Customer(Base):
|
||||
__tablename__ = "customers"
|
||||
id = Column(Integer, primary_key=True)
|
||||
given_name = Column(String)
|
||||
contact_id = Column(String, unique=True)
|
||||
surname = Column(String)
|
||||
name_prefix = Column(String)
|
||||
email_address = Column(String)
|
||||
phone = Column(String)
|
||||
email_newsletter = Column(Boolean)
|
||||
address_line = Column(String)
|
||||
city_name = Column(String)
|
||||
postal_code = Column(String)
|
||||
country_code = Column(String)
|
||||
gender = Column(String)
|
||||
birth_date = Column(String)
|
||||
language = Column(String)
|
||||
address_catalog = Column(Boolean) # Added for XML
|
||||
name_title = Column(String) # Added for XML
|
||||
reservations = relationship("Reservation", back_populates="customer")
|
||||
|
||||
|
||||
class Reservation(Base):
|
||||
__tablename__ = "reservations"
|
||||
id = Column(Integer, primary_key=True)
|
||||
customer_id = Column(Integer, ForeignKey("customers.id"))
|
||||
unique_id = Column(String, unique=True)
|
||||
md5_unique_id = Column(String(32), unique=True) # max length 32 guaranteed
|
||||
start_date = Column(Date)
|
||||
end_date = Column(Date)
|
||||
num_adults = Column(Integer)
|
||||
num_children = Column(Integer)
|
||||
children_ages = Column(String) # comma-separated
|
||||
offer = Column(String)
|
||||
created_at = Column(DateTime)
|
||||
# Add all UTM fields and user comment for XML
|
||||
utm_source = Column(String)
|
||||
utm_medium = Column(String)
|
||||
utm_campaign = Column(String)
|
||||
utm_term = Column(String)
|
||||
utm_content = Column(String)
|
||||
user_comment = Column(String)
|
||||
fbclid = Column(String)
|
||||
gclid = Column(String)
|
||||
# Add hotel_code and hotel_name for XML
|
||||
hotel_code = Column(String)
|
||||
hotel_name = Column(String)
|
||||
customer = relationship("Customer", back_populates="reservations")
|
||||
|
||||
|
||||
# Table for tracking acknowledged requests by client
|
||||
class AckedRequest(Base):
|
||||
__tablename__ = "acked_requests"
|
||||
id = Column(Integer, primary_key=True)
|
||||
client_id = Column(String, index=True)
|
||||
unique_id = Column(
|
||||
String, index=True
|
||||
) # Should match Reservation.form_id or another unique field
|
||||
timestamp = Column(DateTime)
|
||||
@@ -85,6 +85,7 @@ __all__ = [
|
||||
"CommentName1",
|
||||
"CommentName2",
|
||||
"ContactInfoLocation",
|
||||
"DefSendComplete",
|
||||
"DescriptionName",
|
||||
"DescriptionTextFormat1",
|
||||
"DescriptionTextFormat2",
|
||||
@@ -103,6 +104,7 @@ __all__ = [
|
||||
"MealsIncludedMealPlanIndicator",
|
||||
"MultimediaDescriptionInfoCode1",
|
||||
"MultimediaDescriptionInfoCode2",
|
||||
"OccupancyAgeQualifyingCode",
|
||||
"OtaHotelDescriptiveContentNotifRq",
|
||||
"OtaHotelDescriptiveContentNotifRs",
|
||||
"OtaHotelDescriptiveInfoRq",
|
||||
@@ -123,7 +125,6 @@ __all__ = [
|
||||
"OtaPingRs",
|
||||
"OtaReadRq",
|
||||
"OtaResRetrieveRs",
|
||||
"OccupancyAgeQualifyingCode",
|
||||
"PositionAltitudeUnitOfMeasureCode",
|
||||
"PrerequisiteInventoryInvType",
|
||||
"ProfileProfileType",
|
||||
@@ -150,12 +151,11 @@ __all__ = [
|
||||
"TextTextFormat2",
|
||||
"TimeUnitType",
|
||||
"TypeRoomRoomType",
|
||||
"UrlType",
|
||||
"UniqueIdInstance",
|
||||
"UniqueIdType1",
|
||||
"UniqueIdType2",
|
||||
"UniqueIdType3",
|
||||
"UrlType",
|
||||
"VideoItemCategory",
|
||||
"WarningStatus",
|
||||
"DefSendComplete",
|
||||
]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
87
src/alpine_bits_python/logging_config.py
Normal file
87
src/alpine_bits_python/logging_config.py
Normal file
@@ -0,0 +1,87 @@
|
||||
"""Centralized logging configuration for AlpineBits application.
|
||||
|
||||
This module sets up logging based on config and provides a function to get
|
||||
loggers from anywhere in the application.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def setup_logging(config: dict | None = None):
|
||||
"""Configure logging based on application config.
|
||||
|
||||
Args:
|
||||
config: Application configuration dict with optional 'logger' section
|
||||
|
||||
Logger config format:
|
||||
logger:
|
||||
level: "INFO" # DEBUG, INFO, WARNING, ERROR, CRITICAL
|
||||
file: "alpinebits.log" # Optional, logs to console if not provided
|
||||
|
||||
"""
|
||||
if config is None:
|
||||
config = {}
|
||||
|
||||
logger_config = config.get("logger", {})
|
||||
level = logger_config.get("level", "INFO").upper()
|
||||
log_file = logger_config.get("file")
|
||||
|
||||
# Convert string level to logging constant
|
||||
numeric_level = getattr(logging, level, logging.INFO)
|
||||
|
||||
# Create formatter with timestamp
|
||||
formatter = logging.Formatter(
|
||||
fmt="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
||||
datefmt="%Y-%m-%d %H:%M:%S",
|
||||
)
|
||||
|
||||
# Get root logger
|
||||
root_logger = logging.getLogger()
|
||||
root_logger.setLevel(numeric_level)
|
||||
|
||||
# Remove existing handlers to avoid duplicates
|
||||
root_logger.handlers.clear()
|
||||
|
||||
# Console handler (always add this)
|
||||
console_handler = logging.StreamHandler(sys.stdout)
|
||||
console_handler.setLevel(numeric_level)
|
||||
console_handler.setFormatter(formatter)
|
||||
root_logger.addHandler(console_handler)
|
||||
|
||||
# File handler (optional)
|
||||
if log_file:
|
||||
log_path = Path(log_file)
|
||||
|
||||
# Create logs directory if it doesn't exist
|
||||
if log_path.parent != Path():
|
||||
log_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
file_handler = logging.FileHandler(log_file, encoding="utf-8")
|
||||
file_handler.setLevel(numeric_level)
|
||||
file_handler.setFormatter(formatter)
|
||||
root_logger.addHandler(file_handler)
|
||||
|
||||
root_logger.info("Logging to file: %s", log_file)
|
||||
|
||||
root_logger.info("Logging configured at %s level", level)
|
||||
|
||||
|
||||
def get_logger(name: str) -> logging.Logger:
|
||||
"""Get a logger instance for the given module name.
|
||||
|
||||
Usage:
|
||||
from alpine_bits_python.logging_config import get_logger
|
||||
|
||||
_LOGGER = get_logger(__name__)
|
||||
_LOGGER.info("Something happened")
|
||||
|
||||
Args:
|
||||
name: Usually __name__ from the calling module
|
||||
|
||||
Returns:
|
||||
Configured logger instance
|
||||
|
||||
"""
|
||||
return logging.getLogger(name)
|
||||
@@ -1,195 +0,0 @@
|
||||
from .alpinebits_guestrequests import ResGuest, RoomStay
|
||||
from .generated import alpinebits as ab
|
||||
from io import BytesIO
|
||||
import sys
|
||||
from datetime import datetime, timezone
|
||||
import re
|
||||
from xsdata_pydantic.bindings import XmlSerializer
|
||||
|
||||
from .simplified_access import (
|
||||
CommentData,
|
||||
CommentsData,
|
||||
CommentListItemData,
|
||||
CustomerData,
|
||||
|
||||
HotelReservationIdData,
|
||||
PhoneTechType,
|
||||
AlpineBitsFactory,
|
||||
OtaMessageType
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
# Success - use None instead of object() for cleaner XML output
|
||||
success = None
|
||||
|
||||
# UniqueID
|
||||
unique_id = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.UniqueId(
|
||||
type_value=ab.UniqueIdType2.VALUE_14, id="6b34fe24ac2ff811"
|
||||
)
|
||||
|
||||
# TimeSpan - use the actual nested class
|
||||
|
||||
start_date_window = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.RoomStays.RoomStay.TimeSpan.StartDateWindow(
|
||||
earliest_date="2024-10-01", latest_date="2024-10-02"
|
||||
)
|
||||
|
||||
time_span = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.RoomStays.RoomStay.TimeSpan(
|
||||
start_date_window=start_date_window
|
||||
)
|
||||
|
||||
# RoomStay with TimeSpan
|
||||
room_stay = (
|
||||
ab.OtaResRetrieveRs.ReservationsList.HotelReservation.RoomStays.RoomStay(
|
||||
time_span=time_span
|
||||
)
|
||||
)
|
||||
room_stays = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.RoomStays(
|
||||
room_stay=[room_stay]
|
||||
)
|
||||
|
||||
customer_data = CustomerData(
|
||||
given_name="John",
|
||||
surname="Doe",
|
||||
name_prefix="Mr.",
|
||||
phone_numbers=[
|
||||
("+1234567890", PhoneTechType.MOBILE), # Phone number with type
|
||||
("+0987654321", None), # Phone number without type
|
||||
],
|
||||
email_address="john.doe@example.com",
|
||||
email_newsletter=True,
|
||||
address_line="123 Main Street",
|
||||
city_name="Anytown",
|
||||
postal_code="12345",
|
||||
country_code="US",
|
||||
address_catalog=False,
|
||||
gender="Male",
|
||||
birth_date="1980-01-01",
|
||||
language="en",
|
||||
)
|
||||
|
||||
alpine_bits_factory = AlpineBitsFactory()
|
||||
|
||||
res_guests = alpine_bits_factory.create_res_guests(customer_data, OtaMessageType.RETRIEVE)
|
||||
|
||||
hotel_res_id_data = HotelReservationIdData(
|
||||
res_id_type="13",
|
||||
res_id_value=None,
|
||||
res_id_source=None,
|
||||
res_id_source_context="99tales",
|
||||
)
|
||||
# Create HotelReservationId using the factory
|
||||
hotel_res_id = alpine_bits_factory.create(hotel_res_id_data, OtaMessageType.RETRIEVE)
|
||||
|
||||
# Use the actual nested HotelReservationIds class
|
||||
hotel_res_ids = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.ResGlobalInfo.HotelReservationIds(
|
||||
hotel_reservation_id=[hotel_res_id]
|
||||
)
|
||||
|
||||
# Basic property info
|
||||
basic_property_info = ab.OtaResRetrieveRs.ReservationsList.HotelReservation.ResGlobalInfo.BasicPropertyInfo(
|
||||
hotel_code="123", hotel_name="Frangart Inn"
|
||||
)
|
||||
|
||||
comment = CommentData(
|
||||
name= ab.CommentName2.CUSTOMER_COMMENT,
|
||||
text="This is a sample comment.",
|
||||
list_items=[CommentListItemData(
|
||||
value="Landing page comment",
|
||||
language="en",
|
||||
list_item="1",
|
||||
)],
|
||||
|
||||
|
||||
)
|
||||
|
||||
comment2 = CommentData(
|
||||
name= ab.CommentName2.ADDITIONAL_INFO,
|
||||
text="This is a special request comment.",
|
||||
|
||||
)
|
||||
|
||||
comments_data = CommentsData(comments=[comment, comment2])
|
||||
|
||||
|
||||
comments = alpine_bits_factory.create(comments_data, OtaMessageType.RETRIEVE)
|
||||
|
||||
|
||||
|
||||
# ResGlobalInfo
|
||||
res_global_info = (
|
||||
ab.OtaResRetrieveRs.ReservationsList.HotelReservation.ResGlobalInfo(
|
||||
hotel_reservation_ids=hotel_res_ids, basic_property_info=basic_property_info, comments=comments
|
||||
)
|
||||
)
|
||||
|
||||
# Hotel Reservation
|
||||
hotel_reservation = ab.OtaResRetrieveRs.ReservationsList.HotelReservation(
|
||||
create_date_time=datetime.now(timezone.utc).isoformat(),
|
||||
res_status=ab.HotelReservationResStatus.REQUESTED,
|
||||
room_stay_reservation="true",
|
||||
unique_id=unique_id,
|
||||
room_stays=room_stays,
|
||||
res_guests=res_guests,
|
||||
res_global_info=res_global_info,
|
||||
)
|
||||
|
||||
reservations_list = ab.OtaResRetrieveRs.ReservationsList(
|
||||
hotel_reservation=[hotel_reservation]
|
||||
)
|
||||
|
||||
# Root element
|
||||
ota_res_retrieve_rs = ab.OtaResRetrieveRs(
|
||||
version="7.000", success=success, reservations_list=reservations_list
|
||||
)
|
||||
|
||||
# Serialize using Pydantic's model_dump and convert to XML
|
||||
try:
|
||||
# First validate the model
|
||||
ota_res_retrieve_rs.model_validate(ota_res_retrieve_rs.model_dump())
|
||||
print("✅ Pydantic validation successful!")
|
||||
|
||||
# For XML serialization with Pydantic models, we need to use xsdata-pydantic serializer
|
||||
from xsdata.formats.dataclass.serializers.config import SerializerConfig
|
||||
|
||||
config = SerializerConfig(
|
||||
pretty_print=True, xml_declaration=True, encoding="UTF-8"
|
||||
)
|
||||
|
||||
serializer = XmlSerializer(config=config)
|
||||
|
||||
# Use ns_map to control namespace prefixes - set default namespace
|
||||
ns_map = {None: "http://www.opentravel.org/OTA/2003/05"}
|
||||
xml_string = serializer.render(ota_res_retrieve_rs, ns_map=ns_map)
|
||||
|
||||
with open("output.xml", "w", encoding="utf-8") as outfile:
|
||||
outfile.write(xml_string)
|
||||
|
||||
print("✅ XML serialization successful!")
|
||||
print(f"Generated XML written to output.xml")
|
||||
|
||||
# Also print the pretty formatted XML to console
|
||||
print("\n📄 Generated XML:")
|
||||
print(xml_string)
|
||||
|
||||
# Test parsing back
|
||||
from xsdata_pydantic.bindings import XmlParser
|
||||
|
||||
parser = XmlParser()
|
||||
|
||||
with open("output.xml", "r", encoding="utf-8") as infile:
|
||||
xml_content = infile.read()
|
||||
|
||||
parsed_result = parser.from_string(xml_content, ab.OtaResRetrieveRs)
|
||||
|
||||
print("✅ Round-trip validation successful!")
|
||||
print(
|
||||
f"Parsed reservation status: {parsed_result.reservations_list.hotel_reservation[0].res_status}"
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Validation/Serialization failed: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
99
src/alpine_bits_python/rate_limit.py
Normal file
99
src/alpine_bits_python/rate_limit.py
Normal file
@@ -0,0 +1,99 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
import redis
|
||||
from fastapi import Request
|
||||
from slowapi import Limiter, _rate_limit_exceeded_handler
|
||||
from slowapi.errors import RateLimitExceeded
|
||||
from slowapi.util import get_remote_address
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Rate limiting configuration
|
||||
DEFAULT_RATE_LIMIT = "10/minute" # 10 requests per minute per IP
|
||||
WEBHOOK_RATE_LIMIT = "60/minute" # 60 webhook requests per minute per IP
|
||||
BURST_RATE_LIMIT = "3/second" # Max 3 requests per second per IP
|
||||
|
||||
# Redis configuration for distributed rate limiting (optional)
|
||||
REDIS_URL = os.getenv("REDIS_URL", None)
|
||||
|
||||
|
||||
def get_remote_address_with_forwarded(request: Request):
|
||||
"""Get client IP address, considering forwarded headers from proxies/load balancers."""
|
||||
# Check for forwarded headers (common in production behind proxies)
|
||||
forwarded_for = request.headers.get("X-Forwarded-For")
|
||||
if forwarded_for:
|
||||
# Take the first IP in the chain
|
||||
return forwarded_for.split(",")[0].strip()
|
||||
|
||||
real_ip = request.headers.get("X-Real-IP")
|
||||
if real_ip:
|
||||
return real_ip
|
||||
|
||||
# Fallback to direct connection IP
|
||||
return get_remote_address(request)
|
||||
|
||||
|
||||
# Initialize limiter
|
||||
if REDIS_URL:
|
||||
# Use Redis for distributed rate limiting (recommended for production)
|
||||
try:
|
||||
import redis
|
||||
|
||||
redis_client = redis.from_url(REDIS_URL)
|
||||
limiter = Limiter(
|
||||
key_func=get_remote_address_with_forwarded, storage_uri=REDIS_URL
|
||||
)
|
||||
logger.info("Rate limiting initialized with Redis backend")
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"Failed to connect to Redis: {e}. Using in-memory rate limiting."
|
||||
)
|
||||
limiter = Limiter(key_func=get_remote_address_with_forwarded)
|
||||
else:
|
||||
# Use in-memory rate limiting (fine for single instance)
|
||||
limiter = Limiter(key_func=get_remote_address_with_forwarded)
|
||||
logger.info("Rate limiting initialized with in-memory backend")
|
||||
|
||||
|
||||
def get_api_key_identifier(request: Request) -> str:
|
||||
"""Get identifier for rate limiting based on API key if available, otherwise IP
|
||||
This allows different rate limits per API key.
|
||||
"""
|
||||
# Try to get API key from Authorization header
|
||||
auth_header = request.headers.get("Authorization")
|
||||
if auth_header and auth_header.startswith("Bearer "):
|
||||
api_key = auth_header[7:] # Remove "Bearer " prefix
|
||||
# Use first 10 chars of API key as identifier (don't log full key)
|
||||
return f"api_key:{api_key[:10]}"
|
||||
|
||||
# Fallback to IP address
|
||||
return f"ip:{get_remote_address_with_forwarded(request)}"
|
||||
|
||||
|
||||
# Custom rate limit key function for API key based limiting
|
||||
def api_key_rate_limit_key(request: Request):
|
||||
return get_api_key_identifier(request)
|
||||
|
||||
|
||||
# Rate limiting decorators for different endpoint types
|
||||
webhook_limiter = Limiter(
|
||||
key_func=api_key_rate_limit_key, storage_uri=REDIS_URL if REDIS_URL else None
|
||||
)
|
||||
|
||||
|
||||
# Custom rate limit exceeded handler
|
||||
def custom_rate_limit_handler(request: Request, exc: RateLimitExceeded):
|
||||
"""Custom handler for rate limit exceeded."""
|
||||
logger.warning(
|
||||
f"Rate limit exceeded for {get_remote_address_with_forwarded(request)}: "
|
||||
f"{exc.detail}"
|
||||
)
|
||||
|
||||
response = _rate_limit_exceeded_handler(request, exc)
|
||||
|
||||
# Add custom headers
|
||||
response.headers["X-RateLimit-Limit"] = str(exc.retry_after)
|
||||
response.headers["X-RateLimit-Retry-After"] = str(exc.retry_after)
|
||||
|
||||
return response
|
||||
19
src/alpine_bits_python/run_api.py
Normal file
19
src/alpine_bits_python/run_api.py
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Startup script for the Wix Form Handler API."""
|
||||
|
||||
import os
|
||||
|
||||
import uvicorn
|
||||
|
||||
if __name__ == "__main__":
|
||||
db_path = "alpinebits.db" # Adjust path if needed
|
||||
if os.path.exists(db_path):
|
||||
os.remove(db_path)
|
||||
|
||||
uvicorn.run(
|
||||
"alpine_bits_python.api:app",
|
||||
host="0.0.0.0",
|
||||
port=8080,
|
||||
reload=True, # Enable auto-reload during development
|
||||
log_level="info",
|
||||
)
|
||||
254
src/alpine_bits_python/schemas.py
Normal file
254
src/alpine_bits_python/schemas.py
Normal file
@@ -0,0 +1,254 @@
|
||||
"""Pydantic models for data validation in AlpineBits.
|
||||
|
||||
These models provide validation for data before it's passed to:
|
||||
- SQLAlchemy database models
|
||||
- AlpineBits XML generation
|
||||
- API endpoints
|
||||
|
||||
Separating validation (Pydantic) from persistence (SQLAlchemy) and
|
||||
from XML generation (xsdata) follows clean architecture principles.
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
from datetime import date, datetime
|
||||
from enum import Enum
|
||||
|
||||
from pydantic import BaseModel, EmailStr, Field, field_validator, model_validator
|
||||
|
||||
|
||||
# phonetechtype enum 1,3,5 voice, fax, mobile
|
||||
class PhoneTechType(Enum):
|
||||
VOICE = "1"
|
||||
FAX = "3"
|
||||
MOBILE = "5"
|
||||
|
||||
|
||||
class PhoneNumber(BaseModel):
|
||||
"""Phone number with optional type."""
|
||||
|
||||
number: str = Field(..., min_length=1, max_length=50, pattern=r"^\+?[0-9\s\-()]+$")
|
||||
tech_type: str | None = Field(None, pattern="^[135]$") # 1=voice, 3=fax, 5=mobile
|
||||
|
||||
@field_validator("number")
|
||||
@classmethod
|
||||
def clean_phone_number(cls, v: str) -> str:
|
||||
"""Remove extra spaces from phone number."""
|
||||
return " ".join(v.split())
|
||||
|
||||
|
||||
class ReservationData(BaseModel):
|
||||
"""Validated reservation data."""
|
||||
|
||||
unique_id: str = Field(..., min_length=1, max_length=200)
|
||||
md5_unique_id: str | None = Field(None, min_length=1, max_length=32)
|
||||
start_date: date
|
||||
end_date: date
|
||||
created_at: datetime = Field(default_factory=datetime.now)
|
||||
num_adults: int = Field(..., ge=1)
|
||||
num_children: int = Field(0, ge=0, le=10)
|
||||
children_ages: list[int] = Field(default_factory=list)
|
||||
hotel_code: str = Field(..., min_length=1, max_length=50)
|
||||
hotel_name: str | None = Field(None, max_length=200)
|
||||
offer: str | None = Field(None, max_length=500)
|
||||
user_comment: str | None = Field(None, max_length=2000)
|
||||
fbclid: str | None = Field(None, max_length=300)
|
||||
gclid: str | None = Field(None, max_length=300)
|
||||
utm_source: str | None = Field(None, max_length=150)
|
||||
utm_medium: str | None = Field(None, max_length=150)
|
||||
utm_campaign: str | None = Field(None, max_length=150)
|
||||
utm_term: str | None = Field(None, max_length=150)
|
||||
utm_content: str | None = Field(None, max_length=150)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def ensure_md5(self) -> "ReservationData":
|
||||
"""Ensure md5_unique_id is set after model validation.
|
||||
|
||||
Using a model_validator in 'after' mode lets us access all fields via
|
||||
the instance and set md5_unique_id in-place when it wasn't provided.
|
||||
"""
|
||||
if not getattr(self, "md5_unique_id", None) and getattr(
|
||||
self, "unique_id", None
|
||||
):
|
||||
self.md5_unique_id = hashlib.md5(self.unique_id.encode("utf-8")).hexdigest()
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_children_ages(self) -> "ReservationData":
|
||||
"""Ensure children_ages matches num_children."""
|
||||
if len(self.children_ages) != self.num_children:
|
||||
raise ValueError(
|
||||
f"Number of children ages ({len(self.children_ages)}) "
|
||||
f"must match num_children ({self.num_children})"
|
||||
)
|
||||
for age in self.children_ages:
|
||||
if age < 0 or age > 17:
|
||||
raise ValueError(f"Child age {age} must be between 0 and 17")
|
||||
return self
|
||||
|
||||
|
||||
class CustomerData(BaseModel):
|
||||
"""Validated customer data for creating reservations and guests."""
|
||||
|
||||
given_name: str = Field(..., min_length=1, max_length=100)
|
||||
surname: str = Field(..., min_length=1, max_length=100)
|
||||
name_prefix: str | None = Field(None, max_length=20)
|
||||
name_title: str | None = Field(None, max_length=20)
|
||||
phone_numbers: list[tuple[str, None | PhoneTechType]] = Field(default_factory=list)
|
||||
email_address: EmailStr | None = None
|
||||
email_newsletter: bool | None = None
|
||||
address_line: str | None = Field(None, max_length=255)
|
||||
city_name: str | None = Field(None, max_length=100)
|
||||
postal_code: str | None = Field(None, max_length=20)
|
||||
country_code: str | None = Field(
|
||||
None, min_length=2, max_length=2, pattern="^[A-Z]{2}$"
|
||||
)
|
||||
address_catalog: bool | None = None
|
||||
gender: str | None = Field(None, pattern="^(Male|Female|Unknown)$")
|
||||
birth_date: str | None = Field(None, pattern=r"^\d{4}-\d{2}-\d{2}$") # ISO format
|
||||
language: str | None = Field(None, min_length=2, max_length=2, pattern="^[a-z]{2}$")
|
||||
|
||||
@field_validator("given_name", "surname")
|
||||
@classmethod
|
||||
def name_must_not_be_empty(cls, v: str) -> str:
|
||||
"""Ensure names are not just whitespace."""
|
||||
if not v.strip():
|
||||
raise ValueError("Name cannot be empty or whitespace")
|
||||
return v.strip()
|
||||
|
||||
@field_validator("country_code")
|
||||
@classmethod
|
||||
def normalize_country_code(cls, v: str | None) -> str | None:
|
||||
"""Normalize country code to uppercase."""
|
||||
return v.upper() if v else None
|
||||
|
||||
@field_validator("language")
|
||||
@classmethod
|
||||
def normalize_language(cls, v: str | None) -> str | None:
|
||||
"""Normalize language code to lowercase."""
|
||||
return v.lower() if v else None
|
||||
|
||||
model_config = {"from_attributes": True} # Allow creation from ORM models
|
||||
|
||||
|
||||
class HotelReservationIdData(BaseModel):
|
||||
"""Validated hotel reservation ID data."""
|
||||
|
||||
res_id_type: str = Field(..., pattern=r"^[0-9]+$") # Must be numeric string
|
||||
res_id_value: str | None = Field(None, min_length=1, max_length=64)
|
||||
res_id_source: str | None = Field(None, min_length=1, max_length=64)
|
||||
res_id_source_context: str | None = Field(None, min_length=1, max_length=64)
|
||||
|
||||
@field_validator(
|
||||
"res_id_value", "res_id_source", "res_id_source_context", mode="before"
|
||||
)
|
||||
@classmethod
|
||||
def trim_and_truncate(cls, v: str | None) -> str | None:
|
||||
"""Trim whitespace and truncate to max length if needed.
|
||||
|
||||
Runs BEFORE field validation to ensure values are cleaned and truncated
|
||||
before max_length constraints are checked.
|
||||
"""
|
||||
if not v:
|
||||
return None
|
||||
# Convert to string if needed
|
||||
v = str(v)
|
||||
# Strip whitespace
|
||||
v = v.strip()
|
||||
# Convert empty strings to None
|
||||
if not v:
|
||||
return None
|
||||
# Truncate to 64 characters if needed
|
||||
if len(v) > 64:
|
||||
v = v[:64]
|
||||
return v
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class CommentListItemData(BaseModel):
|
||||
"""Validated comment list item."""
|
||||
|
||||
value: str = Field(..., min_length=1, max_length=1000)
|
||||
list_item: str = Field(..., pattern=r"^[0-9]+$") # Numeric identifier
|
||||
language: str = Field(..., min_length=2, max_length=2, pattern=r"^[a-z]{2}$")
|
||||
|
||||
@field_validator("language")
|
||||
@classmethod
|
||||
def normalize_language(cls, v: str) -> str:
|
||||
"""Normalize language to lowercase."""
|
||||
return v.lower()
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class CommentData(BaseModel):
|
||||
"""Validated comment data."""
|
||||
|
||||
name: str # Should be validated against CommentName2 enum
|
||||
text: str | None = Field(None, max_length=4000)
|
||||
list_items: list[CommentListItemData] = Field(default_factory=list)
|
||||
|
||||
@field_validator("list_items")
|
||||
@classmethod
|
||||
def validate_list_items(
|
||||
cls, v: list[CommentListItemData]
|
||||
) -> list[CommentListItemData]:
|
||||
"""Ensure list items have unique identifiers."""
|
||||
if v:
|
||||
item_ids = [item.list_item for item in v]
|
||||
if len(item_ids) != len(set(item_ids)):
|
||||
raise ValueError("List items must have unique identifiers")
|
||||
return v
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class CommentsData(BaseModel):
|
||||
"""Validated comments collection."""
|
||||
|
||||
comments: list[CommentData] = Field(default_factory=list, max_length=3)
|
||||
|
||||
@field_validator("comments")
|
||||
@classmethod
|
||||
def validate_comment_count(cls, v: list[CommentData]) -> list[CommentData]:
|
||||
"""Ensure maximum 3 comments."""
|
||||
if len(v) > 3:
|
||||
raise ValueError("Maximum 3 comments allowed")
|
||||
return v
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
# Example usage in a service layer
|
||||
class ReservationService:
|
||||
"""Example service showing how to use Pydantic models with SQLAlchemy."""
|
||||
|
||||
def __init__(self, db_session):
|
||||
self.db_session = db_session
|
||||
|
||||
async def create_reservation(
|
||||
self, reservation_data: ReservationData, customer_data: CustomerData
|
||||
):
|
||||
"""Create a reservation with validated data.
|
||||
|
||||
The data has already been validated by Pydantic before reaching here.
|
||||
"""
|
||||
from alpine_bits_python.db import Customer, Reservation
|
||||
|
||||
# Convert validated Pydantic model to SQLAlchemy model
|
||||
db_customer = Customer(**customer_data.model_dump(exclude_none=True))
|
||||
self.db_session.add(db_customer)
|
||||
await self.db_session.flush() # Get the customer ID
|
||||
|
||||
# Create reservation linked to customer
|
||||
db_reservation = Reservation(
|
||||
customer_id=db_customer.id,
|
||||
**reservation_data.model_dump(
|
||||
exclude={"children_ages"}
|
||||
), # Handle separately
|
||||
children_ages=",".join(map(str, reservation_data.children_ages)),
|
||||
)
|
||||
self.db_session.add(db_reservation)
|
||||
await self.db_session.commit()
|
||||
|
||||
return db_reservation, db_customer
|
||||
@@ -1,740 +0,0 @@
|
||||
from typing import Union, Optional, Any, TypeVar
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
|
||||
# Import the generated classes
|
||||
from .generated.alpinebits import OtaHotelResNotifRq, OtaResRetrieveRs, CommentName2
|
||||
|
||||
# Define type aliases for the two Customer types
|
||||
NotifCustomer = OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGuests.ResGuest.Profiles.ProfileInfo.Profile.Customer
|
||||
RetrieveCustomer = OtaResRetrieveRs.ReservationsList.HotelReservation.ResGuests.ResGuest.Profiles.ProfileInfo.Profile.Customer
|
||||
|
||||
# Define type aliases for HotelReservationId types
|
||||
NotifHotelReservationId = OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGlobalInfo.HotelReservationIds.HotelReservationId
|
||||
RetrieveHotelReservationId = OtaResRetrieveRs.ReservationsList.HotelReservation.ResGlobalInfo.HotelReservationIds.HotelReservationId
|
||||
|
||||
# Define type aliases for Comments types
|
||||
NotifComments = OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGlobalInfo.Comments
|
||||
RetrieveComments = OtaResRetrieveRs.ReservationsList.HotelReservation.ResGlobalInfo.Comments
|
||||
NotifComment = OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGlobalInfo.Comments.Comment
|
||||
RetrieveComment = OtaResRetrieveRs.ReservationsList.HotelReservation.ResGlobalInfo.Comments.Comment
|
||||
|
||||
|
||||
# phonetechtype enum 1,3,5 voice, fax, mobile
|
||||
class PhoneTechType(Enum):
|
||||
VOICE = "1"
|
||||
FAX = "3"
|
||||
MOBILE = "5"
|
||||
|
||||
|
||||
# Enum to specify which OTA message type to use
|
||||
class OtaMessageType(Enum):
|
||||
NOTIF = "notification" # For OtaHotelResNotifRq
|
||||
RETRIEVE = "retrieve" # For OtaResRetrieveRs
|
||||
|
||||
|
||||
@dataclass
|
||||
class CustomerData:
|
||||
"""Simple data class to hold customer information without nested type constraints."""
|
||||
|
||||
given_name: str
|
||||
surname: str
|
||||
name_prefix: None | str = None
|
||||
name_title: None | str = None
|
||||
phone_numbers: list[tuple[str, None | PhoneTechType]] = (
|
||||
None # (phone_number, phone_tech_type)
|
||||
)
|
||||
email_address: None | str = None
|
||||
email_newsletter: None | bool = (
|
||||
None # True for "yes", False for "no", None for not specified
|
||||
)
|
||||
address_line: None | str = None
|
||||
city_name: None | str = None
|
||||
postal_code: None | str = None
|
||||
country_code: None | str = None # Two-letter country code
|
||||
address_catalog: None | bool = (
|
||||
None # True for "yes", False for "no", None for not specified
|
||||
)
|
||||
gender: None | str = None # "Unknown", "Male", "Female"
|
||||
birth_date: None | str = None
|
||||
language: None | str = None # Two-letter language code
|
||||
|
||||
def __post_init__(self):
|
||||
if self.phone_numbers is None:
|
||||
self.phone_numbers = []
|
||||
|
||||
|
||||
class CustomerFactory:
|
||||
"""Factory class to create Customer instances for both OtaHotelResNotifRq and OtaResRetrieveRs."""
|
||||
|
||||
@staticmethod
|
||||
def create_notif_customer(data: CustomerData) -> NotifCustomer:
|
||||
"""Create a Customer for OtaHotelResNotifRq."""
|
||||
return CustomerFactory._create_customer(NotifCustomer, data)
|
||||
|
||||
@staticmethod
|
||||
def create_retrieve_customer(data: CustomerData) -> RetrieveCustomer:
|
||||
"""Create a Customer for OtaResRetrieveRs."""
|
||||
return CustomerFactory._create_customer(RetrieveCustomer, data)
|
||||
|
||||
@staticmethod
|
||||
def _create_customer(customer_class: type, data: CustomerData) -> Any:
|
||||
"""Internal method to create a customer of the specified type."""
|
||||
|
||||
# Create PersonName
|
||||
person_name = customer_class.PersonName(
|
||||
given_name=data.given_name,
|
||||
surname=data.surname,
|
||||
name_prefix=data.name_prefix,
|
||||
name_title=data.name_title,
|
||||
)
|
||||
|
||||
# Create telephone list
|
||||
telephones = []
|
||||
for phone_number, phone_tech_type in data.phone_numbers:
|
||||
telephone = customer_class.Telephone(
|
||||
phone_number=phone_number,
|
||||
phone_tech_type=phone_tech_type.value if phone_tech_type else None,
|
||||
)
|
||||
telephones.append(telephone)
|
||||
|
||||
# Create email if provided
|
||||
email = None
|
||||
if data.email_address:
|
||||
remark = None
|
||||
if data.email_newsletter is not None:
|
||||
remark = f"newsletter:{'yes' if data.email_newsletter else 'no'}"
|
||||
|
||||
email = customer_class.Email(value=data.email_address, remark=remark)
|
||||
|
||||
# Create address if any address fields are provided
|
||||
address = None
|
||||
if any(
|
||||
[data.address_line, data.city_name, data.postal_code, data.country_code]
|
||||
):
|
||||
country_name = None
|
||||
if data.country_code:
|
||||
country_name = customer_class.Address.CountryName(
|
||||
code=data.country_code
|
||||
)
|
||||
|
||||
address_remark = None
|
||||
if data.address_catalog is not None:
|
||||
address_remark = f"catalog:{'yes' if data.address_catalog else 'no'}"
|
||||
|
||||
address = customer_class.Address(
|
||||
address_line=data.address_line,
|
||||
city_name=data.city_name,
|
||||
postal_code=data.postal_code,
|
||||
country_name=country_name,
|
||||
remark=address_remark,
|
||||
)
|
||||
|
||||
# Create the customer
|
||||
return customer_class(
|
||||
person_name=person_name,
|
||||
telephone=telephones,
|
||||
email=email,
|
||||
address=address,
|
||||
gender=data.gender,
|
||||
birth_date=data.birth_date,
|
||||
language=data.language,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_notif_customer(customer: NotifCustomer) -> CustomerData:
|
||||
"""Convert a NotifCustomer back to CustomerData."""
|
||||
return CustomerFactory._customer_to_data(customer)
|
||||
|
||||
@staticmethod
|
||||
def from_retrieve_customer(customer: RetrieveCustomer) -> CustomerData:
|
||||
"""Convert a RetrieveCustomer back to CustomerData."""
|
||||
return CustomerFactory._customer_to_data(customer)
|
||||
|
||||
@staticmethod
|
||||
def _customer_to_data(customer: Any) -> CustomerData:
|
||||
"""Internal method to convert any customer type to CustomerData."""
|
||||
|
||||
# Extract phone numbers
|
||||
phone_numbers = []
|
||||
if customer.telephone:
|
||||
for tel in customer.telephone:
|
||||
phone_numbers.append(
|
||||
(
|
||||
tel.phone_number,
|
||||
PhoneTechType(tel.phone_tech_type)
|
||||
if tel.phone_tech_type
|
||||
else None,
|
||||
)
|
||||
)
|
||||
|
||||
# Extract email info
|
||||
email_address = None
|
||||
email_newsletter = None
|
||||
if customer.email:
|
||||
email_address = customer.email.value
|
||||
if customer.email.remark:
|
||||
if "newsletter:yes" in customer.email.remark:
|
||||
email_newsletter = True
|
||||
elif "newsletter:no" in customer.email.remark:
|
||||
email_newsletter = False
|
||||
|
||||
# Extract address info
|
||||
address_line = None
|
||||
city_name = None
|
||||
postal_code = None
|
||||
country_code = None
|
||||
address_catalog = None
|
||||
|
||||
if customer.address:
|
||||
address_line = customer.address.address_line
|
||||
city_name = customer.address.city_name
|
||||
postal_code = customer.address.postal_code
|
||||
|
||||
if customer.address.country_name:
|
||||
country_code = customer.address.country_name.code
|
||||
|
||||
if customer.address.remark:
|
||||
if "catalog:yes" in customer.address.remark:
|
||||
address_catalog = True
|
||||
elif "catalog:no" in customer.address.remark:
|
||||
address_catalog = False
|
||||
|
||||
return CustomerData(
|
||||
given_name=customer.person_name.given_name,
|
||||
surname=customer.person_name.surname,
|
||||
name_prefix=customer.person_name.name_prefix,
|
||||
name_title=customer.person_name.name_title,
|
||||
phone_numbers=phone_numbers,
|
||||
email_address=email_address,
|
||||
email_newsletter=email_newsletter,
|
||||
address_line=address_line,
|
||||
city_name=city_name,
|
||||
postal_code=postal_code,
|
||||
country_code=country_code,
|
||||
address_catalog=address_catalog,
|
||||
gender=customer.gender,
|
||||
birth_date=customer.birth_date,
|
||||
language=customer.language,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class HotelReservationIdData:
|
||||
"""Simple data class to hold hotel reservation ID information without nested type constraints."""
|
||||
|
||||
res_id_type: str # Required field - pattern: [0-9]+
|
||||
res_id_value: None | str = None # Max 64 characters
|
||||
res_id_source: None | str = None # Max 64 characters
|
||||
res_id_source_context: None | str = None # Max 64 characters
|
||||
|
||||
|
||||
class HotelReservationIdFactory:
|
||||
"""Factory class to create HotelReservationId instances for both OtaHotelResNotifRq and OtaResRetrieveRs."""
|
||||
|
||||
@staticmethod
|
||||
def create_notif_hotel_reservation_id(
|
||||
data: HotelReservationIdData,
|
||||
) -> NotifHotelReservationId:
|
||||
"""Create a HotelReservationId for OtaHotelResNotifRq."""
|
||||
return HotelReservationIdFactory._create_hotel_reservation_id(
|
||||
NotifHotelReservationId, data
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create_retrieve_hotel_reservation_id(
|
||||
data: HotelReservationIdData,
|
||||
) -> RetrieveHotelReservationId:
|
||||
"""Create a HotelReservationId for OtaResRetrieveRs."""
|
||||
return HotelReservationIdFactory._create_hotel_reservation_id(
|
||||
RetrieveHotelReservationId, data
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _create_hotel_reservation_id(
|
||||
hotel_reservation_id_class: type, data: HotelReservationIdData
|
||||
) -> Any:
|
||||
"""Internal method to create a hotel reservation id of the specified type."""
|
||||
return hotel_reservation_id_class(
|
||||
res_id_type=data.res_id_type,
|
||||
res_id_value=data.res_id_value,
|
||||
res_id_source=data.res_id_source,
|
||||
res_id_source_context=data.res_id_source_context,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_notif_hotel_reservation_id(
|
||||
hotel_reservation_id: NotifHotelReservationId,
|
||||
) -> HotelReservationIdData:
|
||||
"""Convert a NotifHotelReservationId back to HotelReservationIdData."""
|
||||
return HotelReservationIdFactory._hotel_reservation_id_to_data(
|
||||
hotel_reservation_id
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_retrieve_hotel_reservation_id(
|
||||
hotel_reservation_id: RetrieveHotelReservationId,
|
||||
) -> HotelReservationIdData:
|
||||
"""Convert a RetrieveHotelReservationId back to HotelReservationIdData."""
|
||||
return HotelReservationIdFactory._hotel_reservation_id_to_data(
|
||||
hotel_reservation_id
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _hotel_reservation_id_to_data(
|
||||
hotel_reservation_id: Any,
|
||||
) -> HotelReservationIdData:
|
||||
"""Internal method to convert any hotel reservation id type to HotelReservationIdData."""
|
||||
return HotelReservationIdData(
|
||||
res_id_type=hotel_reservation_id.res_id_type,
|
||||
res_id_value=hotel_reservation_id.res_id_value,
|
||||
res_id_source=hotel_reservation_id.res_id_source,
|
||||
res_id_source_context=hotel_reservation_id.res_id_source_context,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class CommentListItemData:
|
||||
"""Simple data class to hold comment list item information."""
|
||||
value: str # The text content of the list item
|
||||
list_item: str # Numeric identifier (pattern: [0-9]+)
|
||||
language: str # Two-letter language code (pattern: [a-z][a-z])
|
||||
|
||||
|
||||
@dataclass
|
||||
class CommentData:
|
||||
"""Simple data class to hold comment information without nested type constraints."""
|
||||
name: CommentName2 # Required: "included services", "customer comment", "additional info"
|
||||
text: Optional[str] = None # Optional text content
|
||||
list_items: list[CommentListItemData] = None # Optional list items
|
||||
|
||||
def __post_init__(self):
|
||||
if self.list_items is None:
|
||||
self.list_items = []
|
||||
|
||||
|
||||
@dataclass
|
||||
class CommentsData:
|
||||
"""Simple data class to hold multiple comments (1-3 max)."""
|
||||
comments: list[CommentData] = None # 1-3 comments maximum
|
||||
|
||||
def __post_init__(self):
|
||||
if self.comments is None:
|
||||
self.comments = []
|
||||
|
||||
|
||||
class CommentFactory:
|
||||
"""Factory class to create Comment instances for both OtaHotelResNotifRq and OtaResRetrieveRs."""
|
||||
|
||||
@staticmethod
|
||||
def create_notif_comments(data: CommentsData) -> NotifComments:
|
||||
"""Create Comments for OtaHotelResNotifRq."""
|
||||
return CommentFactory._create_comments(NotifComments, NotifComment, data)
|
||||
|
||||
@staticmethod
|
||||
def create_retrieve_comments(data: CommentsData) -> RetrieveComments:
|
||||
"""Create Comments for OtaResRetrieveRs."""
|
||||
return CommentFactory._create_comments(RetrieveComments, RetrieveComment, data)
|
||||
|
||||
@staticmethod
|
||||
def _create_comments(comments_class: type, comment_class: type, data: CommentsData) -> Any:
|
||||
"""Internal method to create comments of the specified type."""
|
||||
|
||||
comments_list = []
|
||||
for comment_data in data.comments:
|
||||
# Create list items
|
||||
list_items = []
|
||||
for item_data in comment_data.list_items:
|
||||
list_item = comment_class.ListItem(
|
||||
value=item_data.value,
|
||||
list_item=item_data.list_item,
|
||||
language=item_data.language
|
||||
)
|
||||
list_items.append(list_item)
|
||||
|
||||
# Create comment
|
||||
comment = comment_class(
|
||||
name=comment_data.name,
|
||||
text=comment_data.text,
|
||||
list_item=list_items
|
||||
)
|
||||
comments_list.append(comment)
|
||||
|
||||
# Create comments container
|
||||
return comments_class(comment=comments_list)
|
||||
|
||||
@staticmethod
|
||||
def from_notif_comments(comments: NotifComments) -> CommentsData:
|
||||
"""Convert NotifComments back to CommentsData."""
|
||||
return CommentFactory._comments_to_data(comments)
|
||||
|
||||
@staticmethod
|
||||
def from_retrieve_comments(comments: RetrieveComments) -> CommentsData:
|
||||
"""Convert RetrieveComments back to CommentsData."""
|
||||
return CommentFactory._comments_to_data(comments)
|
||||
|
||||
@staticmethod
|
||||
def _comments_to_data(comments: Any) -> CommentsData:
|
||||
"""Internal method to convert any comments type to CommentsData."""
|
||||
|
||||
comments_data_list = []
|
||||
for comment in comments.comment:
|
||||
# Extract list items
|
||||
list_items_data = []
|
||||
if comment.list_item:
|
||||
for list_item in comment.list_item:
|
||||
list_items_data.append(CommentListItemData(
|
||||
value=list_item.value,
|
||||
list_item=list_item.list_item,
|
||||
language=list_item.language
|
||||
))
|
||||
|
||||
# Extract comment data
|
||||
comment_data = CommentData(
|
||||
name=comment.name,
|
||||
text=comment.text,
|
||||
list_items=list_items_data
|
||||
)
|
||||
comments_data_list.append(comment_data)
|
||||
|
||||
return CommentsData(comments=comments_data_list)
|
||||
|
||||
|
||||
# Define type aliases for ResGuests types
|
||||
NotifResGuests = OtaHotelResNotifRq.HotelReservations.HotelReservation.ResGuests
|
||||
RetrieveResGuests = OtaResRetrieveRs.ReservationsList.HotelReservation.ResGuests
|
||||
|
||||
|
||||
class ResGuestFactory:
|
||||
"""Factory class to create complete ResGuests structures with a primary customer."""
|
||||
|
||||
@staticmethod
|
||||
def create_notif_res_guests(customer_data: CustomerData) -> NotifResGuests:
|
||||
"""Create a complete ResGuests structure for OtaHotelResNotifRq with primary customer."""
|
||||
return ResGuestFactory._create_res_guests(
|
||||
NotifResGuests, NotifCustomer, customer_data
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create_retrieve_res_guests(customer_data: CustomerData) -> RetrieveResGuests:
|
||||
"""Create a complete ResGuests structure for OtaResRetrieveRs with primary customer."""
|
||||
return ResGuestFactory._create_res_guests(
|
||||
RetrieveResGuests, RetrieveCustomer, customer_data
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _create_res_guests(
|
||||
res_guests_class: type, customer_class: type, customer_data: CustomerData
|
||||
) -> Any:
|
||||
"""Internal method to create complete ResGuests structure."""
|
||||
|
||||
# Create the customer using the existing CustomerFactory
|
||||
customer = CustomerFactory._create_customer(customer_class, customer_data)
|
||||
|
||||
# Create Profile with the customer
|
||||
profile = res_guests_class.ResGuest.Profiles.ProfileInfo.Profile(
|
||||
customer=customer
|
||||
)
|
||||
|
||||
# Create ProfileInfo with the profile
|
||||
profile_info = res_guests_class.ResGuest.Profiles.ProfileInfo(profile=profile)
|
||||
|
||||
# Create Profiles with the profile_info
|
||||
profiles = res_guests_class.ResGuest.Profiles(profile_info=profile_info)
|
||||
|
||||
# Create ResGuest with the profiles
|
||||
res_guest = res_guests_class.ResGuest(profiles=profiles)
|
||||
|
||||
# Create ResGuests with the res_guest
|
||||
return res_guests_class(res_guest=res_guest)
|
||||
|
||||
@staticmethod
|
||||
def extract_primary_customer(
|
||||
res_guests: Union[NotifResGuests, RetrieveResGuests],
|
||||
) -> CustomerData:
|
||||
"""Extract the primary customer data from a ResGuests structure."""
|
||||
|
||||
# Navigate down the nested structure to get the customer
|
||||
customer = res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
|
||||
# Use the existing CustomerFactory conversion method
|
||||
if isinstance(res_guests, NotifResGuests):
|
||||
return CustomerFactory.from_notif_customer(customer)
|
||||
else:
|
||||
return CustomerFactory.from_retrieve_customer(customer)
|
||||
|
||||
|
||||
class AlpineBitsFactory:
|
||||
"""Unified factory class for creating AlpineBits objects with a simple interface."""
|
||||
|
||||
@staticmethod
|
||||
def create(data: Union[CustomerData, HotelReservationIdData, CommentsData], message_type: OtaMessageType) -> Any:
|
||||
"""
|
||||
Create an AlpineBits object based on the data type and message type.
|
||||
|
||||
Args:
|
||||
data: The data object (CustomerData, HotelReservationIdData, CommentsData, etc.)
|
||||
message_type: Whether to create for NOTIF or RETRIEVE message types
|
||||
|
||||
Returns:
|
||||
The appropriate AlpineBits object based on the data type and message type
|
||||
"""
|
||||
if isinstance(data, CustomerData):
|
||||
if message_type == OtaMessageType.NOTIF:
|
||||
return CustomerFactory.create_notif_customer(data)
|
||||
else:
|
||||
return CustomerFactory.create_retrieve_customer(data)
|
||||
|
||||
elif isinstance(data, HotelReservationIdData):
|
||||
if message_type == OtaMessageType.NOTIF:
|
||||
return HotelReservationIdFactory.create_notif_hotel_reservation_id(data)
|
||||
else:
|
||||
return HotelReservationIdFactory.create_retrieve_hotel_reservation_id(data)
|
||||
|
||||
elif isinstance(data, CommentsData):
|
||||
if message_type == OtaMessageType.NOTIF:
|
||||
return CommentFactory.create_notif_comments(data)
|
||||
else:
|
||||
return CommentFactory.create_retrieve_comments(data)
|
||||
|
||||
else:
|
||||
raise ValueError(f"Unsupported data type: {type(data)}")
|
||||
|
||||
@staticmethod
|
||||
def create_res_guests(customer_data: CustomerData, message_type: OtaMessageType) -> Union[NotifResGuests, RetrieveResGuests]:
|
||||
"""
|
||||
Create a complete ResGuests structure with a primary customer.
|
||||
|
||||
Args:
|
||||
customer_data: The customer data
|
||||
message_type: Whether to create for NOTIF or RETRIEVE message types
|
||||
|
||||
Returns:
|
||||
The appropriate ResGuests object
|
||||
"""
|
||||
if message_type == OtaMessageType.NOTIF:
|
||||
return ResGuestFactory.create_notif_res_guests(customer_data)
|
||||
else:
|
||||
return ResGuestFactory.create_retrieve_res_guests(customer_data)
|
||||
|
||||
@staticmethod
|
||||
def extract_data(obj: Any) -> Union[CustomerData, HotelReservationIdData, CommentsData]:
|
||||
"""
|
||||
Extract data from an AlpineBits object back to a simple data class.
|
||||
|
||||
Args:
|
||||
obj: The AlpineBits object to extract data from
|
||||
|
||||
Returns:
|
||||
The appropriate data object
|
||||
"""
|
||||
# Check if it's a Customer object
|
||||
if hasattr(obj, 'person_name') and hasattr(obj.person_name, 'given_name'):
|
||||
if isinstance(obj, NotifCustomer):
|
||||
return CustomerFactory.from_notif_customer(obj)
|
||||
elif isinstance(obj, RetrieveCustomer):
|
||||
return CustomerFactory.from_retrieve_customer(obj)
|
||||
|
||||
# Check if it's a HotelReservationId object
|
||||
elif hasattr(obj, 'res_id_type'):
|
||||
if isinstance(obj, NotifHotelReservationId):
|
||||
return HotelReservationIdFactory.from_notif_hotel_reservation_id(obj)
|
||||
elif isinstance(obj, RetrieveHotelReservationId):
|
||||
return HotelReservationIdFactory.from_retrieve_hotel_reservation_id(obj)
|
||||
|
||||
# Check if it's a Comments object
|
||||
elif hasattr(obj, 'comment'):
|
||||
if isinstance(obj, NotifComments):
|
||||
return CommentFactory.from_notif_comments(obj)
|
||||
elif isinstance(obj, RetrieveComments):
|
||||
return CommentFactory.from_retrieve_comments(obj)
|
||||
|
||||
# Check if it's a ResGuests object
|
||||
elif hasattr(obj, 'res_guest'):
|
||||
return ResGuestFactory.extract_primary_customer(obj)
|
||||
|
||||
else:
|
||||
raise ValueError(f"Unsupported object type: {type(obj)}")
|
||||
|
||||
|
||||
# Usage examples
|
||||
if __name__ == "__main__":
|
||||
# Create customer data using simple data class
|
||||
customer_data = CustomerData(
|
||||
given_name="John",
|
||||
surname="Doe",
|
||||
name_prefix="Mr.",
|
||||
phone_numbers=[
|
||||
("+1234567890", PhoneTechType.MOBILE), # Phone number with type
|
||||
("+0987654321", None), # Phone number without type
|
||||
],
|
||||
email_address="john.doe@example.com",
|
||||
email_newsletter=True,
|
||||
address_line="123 Main Street",
|
||||
city_name="Anytown",
|
||||
postal_code="12345",
|
||||
country_code="US",
|
||||
address_catalog=False,
|
||||
gender="Male",
|
||||
birth_date="1980-01-01",
|
||||
language="en",
|
||||
)
|
||||
|
||||
# Create customer for OtaHotelResNotifRq
|
||||
notif_customer = CustomerFactory.create_notif_customer(customer_data)
|
||||
print(
|
||||
"Created NotifCustomer:",
|
||||
notif_customer.person_name.given_name,
|
||||
notif_customer.person_name.surname,
|
||||
)
|
||||
|
||||
# Create customer for OtaResRetrieveRs
|
||||
retrieve_customer = CustomerFactory.create_retrieve_customer(customer_data)
|
||||
print(
|
||||
"Created RetrieveCustomer:",
|
||||
retrieve_customer.person_name.given_name,
|
||||
retrieve_customer.person_name.surname,
|
||||
)
|
||||
|
||||
# Convert back to data class
|
||||
converted_data = CustomerFactory.from_notif_customer(notif_customer)
|
||||
print("Converted back to data:", converted_data.given_name, converted_data.surname)
|
||||
|
||||
# Verify they contain the same information
|
||||
print("Original and converted data match:", customer_data == converted_data)
|
||||
|
||||
print("\n--- HotelReservationIdFactory Examples ---")
|
||||
|
||||
# Create hotel reservation ID data
|
||||
reservation_id_data = HotelReservationIdData(
|
||||
res_id_type="123",
|
||||
res_id_value="RESERVATION-456",
|
||||
res_id_source="HOTEL_SYSTEM",
|
||||
res_id_source_context="BOOKING_ENGINE",
|
||||
)
|
||||
|
||||
# Create HotelReservationId for both types
|
||||
notif_res_id = HotelReservationIdFactory.create_notif_hotel_reservation_id(
|
||||
reservation_id_data
|
||||
)
|
||||
retrieve_res_id = HotelReservationIdFactory.create_retrieve_hotel_reservation_id(
|
||||
reservation_id_data
|
||||
)
|
||||
|
||||
print(
|
||||
"Created NotifHotelReservationId:",
|
||||
notif_res_id.res_id_type,
|
||||
notif_res_id.res_id_value,
|
||||
)
|
||||
print(
|
||||
"Created RetrieveHotelReservationId:",
|
||||
retrieve_res_id.res_id_type,
|
||||
retrieve_res_id.res_id_value,
|
||||
)
|
||||
|
||||
# Convert back to data class
|
||||
converted_res_id_data = HotelReservationIdFactory.from_notif_hotel_reservation_id(
|
||||
notif_res_id
|
||||
)
|
||||
print(
|
||||
"Converted back to reservation ID data:",
|
||||
converted_res_id_data.res_id_type,
|
||||
converted_res_id_data.res_id_value,
|
||||
)
|
||||
|
||||
# Verify they contain the same information
|
||||
print(
|
||||
"Original and converted reservation ID data match:",
|
||||
reservation_id_data == converted_res_id_data,
|
||||
)
|
||||
|
||||
print("\n--- ResGuestFactory Examples ---")
|
||||
|
||||
# Create complete ResGuests structure for OtaHotelResNotifRq - much simpler!
|
||||
notif_res_guests = ResGuestFactory.create_notif_res_guests(customer_data)
|
||||
print(
|
||||
"Created NotifResGuests with customer:",
|
||||
notif_res_guests.res_guest.profiles.profile_info.profile.customer.person_name.given_name,
|
||||
)
|
||||
|
||||
# Create complete ResGuests structure for OtaResRetrieveRs - much simpler!
|
||||
retrieve_res_guests = ResGuestFactory.create_retrieve_res_guests(customer_data)
|
||||
print(
|
||||
"Created RetrieveResGuests with customer:",
|
||||
retrieve_res_guests.res_guest.profiles.profile_info.profile.customer.person_name.given_name,
|
||||
)
|
||||
|
||||
# Extract primary customer data back from ResGuests structure
|
||||
extracted_data = ResGuestFactory.extract_primary_customer(retrieve_res_guests)
|
||||
print("Extracted customer data:", extracted_data.given_name, extracted_data.surname)
|
||||
|
||||
# Verify roundtrip conversion
|
||||
print("Roundtrip conversion successful:", customer_data == extracted_data)
|
||||
|
||||
print("\n--- Unified AlpineBitsFactory Examples ---")
|
||||
|
||||
# Much simpler approach - single factory with enum parameter!
|
||||
print("=== Customer Creation ===")
|
||||
notif_customer = AlpineBitsFactory.create(customer_data, OtaMessageType.NOTIF)
|
||||
retrieve_customer = AlpineBitsFactory.create(customer_data, OtaMessageType.RETRIEVE)
|
||||
print("Created customers using unified factory")
|
||||
|
||||
print("=== HotelReservationId Creation ===")
|
||||
reservation_id_data = HotelReservationIdData(
|
||||
res_id_type="123",
|
||||
res_id_value="RESERVATION-456",
|
||||
res_id_source="HOTEL_SYSTEM"
|
||||
)
|
||||
notif_res_id = AlpineBitsFactory.create(reservation_id_data, OtaMessageType.NOTIF)
|
||||
retrieve_res_id = AlpineBitsFactory.create(reservation_id_data, OtaMessageType.RETRIEVE)
|
||||
print("Created reservation IDs using unified factory")
|
||||
|
||||
print("=== Comments Creation ===")
|
||||
comments_data = CommentsData(comments=[
|
||||
CommentData(
|
||||
name=CommentName2.CUSTOMER_COMMENT,
|
||||
text="This is a customer comment about the reservation",
|
||||
list_items=[
|
||||
CommentListItemData(
|
||||
value="Special dietary requirements: vegetarian",
|
||||
list_item="1",
|
||||
language="en"
|
||||
),
|
||||
CommentListItemData(
|
||||
value="Late arrival expected",
|
||||
list_item="2",
|
||||
language="en"
|
||||
)
|
||||
]
|
||||
),
|
||||
CommentData(
|
||||
name=CommentName2.ADDITIONAL_INFO,
|
||||
text="Additional information about the stay"
|
||||
)
|
||||
])
|
||||
notif_comments = AlpineBitsFactory.create(comments_data, OtaMessageType.NOTIF)
|
||||
retrieve_comments = AlpineBitsFactory.create(comments_data, OtaMessageType.RETRIEVE)
|
||||
print("Created comments using unified factory")
|
||||
|
||||
print("=== ResGuests Creation ===")
|
||||
notif_res_guests = AlpineBitsFactory.create_res_guests(customer_data, OtaMessageType.NOTIF)
|
||||
retrieve_res_guests = AlpineBitsFactory.create_res_guests(customer_data, OtaMessageType.RETRIEVE)
|
||||
print("Created ResGuests using unified factory")
|
||||
|
||||
print("=== Data Extraction ===")
|
||||
# Extract data back using unified interface
|
||||
extracted_customer_data = AlpineBitsFactory.extract_data(notif_customer)
|
||||
extracted_res_id_data = AlpineBitsFactory.extract_data(notif_res_id)
|
||||
extracted_comments_data = AlpineBitsFactory.extract_data(retrieve_comments)
|
||||
extracted_from_res_guests = AlpineBitsFactory.extract_data(retrieve_res_guests)
|
||||
|
||||
print("Data extraction successful:")
|
||||
print("- Customer roundtrip:", customer_data == extracted_customer_data)
|
||||
print("- ReservationId roundtrip:", reservation_id_data == extracted_res_id_data)
|
||||
print("- Comments roundtrip:", comments_data == extracted_comments_data)
|
||||
print("- ResGuests roundtrip:", customer_data == extracted_from_res_guests)
|
||||
|
||||
print("\n--- Comparison with old approach ---")
|
||||
print("Old way required multiple imports and knowing specific factory methods")
|
||||
print("New way: single import, single factory, enum parameter to specify type!")
|
||||
108
src/alpine_bits_python/templates/index.html
Normal file
108
src/alpine_bits_python/templates/index.html
Normal file
@@ -0,0 +1,108 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>99 Tales - Under Construction</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: 'Arial', sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 600px;
|
||||
padding: 2rem;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 20px;
|
||||
backdrop-filter: blur(10px);
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
margin-bottom: 1rem;
|
||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 2rem;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-size: 1.1rem;
|
||||
line-height: 1.6;
|
||||
margin-bottom: 2rem;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.construction-icon {
|
||||
font-size: 4rem;
|
||||
margin-bottom: 1rem;
|
||||
animation: bounce 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes bounce {
|
||||
0%, 20%, 50%, 80%, 100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
40% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
60% {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
}
|
||||
|
||||
.contact-info {
|
||||
margin-top: 2rem;
|
||||
font-size: 0.9rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.api-link {
|
||||
display: inline-block;
|
||||
margin-top: 1rem;
|
||||
padding: 0.5rem 1rem;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 10px;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.api-link:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="construction-icon">🏗️</div>
|
||||
<h1>99 Tales</h1>
|
||||
<div class="subtitle">Coming Soon</div>
|
||||
<div class="description">
|
||||
We're working hard to bring you something amazing. Our team is putting the finishing touches on an exciting new experience.
|
||||
</div>
|
||||
<div class="description">
|
||||
Thank you for your patience while we build something special for you.
|
||||
</div>
|
||||
<a href="/api" class="api-link">API Documentation</a>
|
||||
<div class="contact-info">
|
||||
Check back soon for updates!
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +1 @@
|
||||
"""Utility functions for alpine_bits_python."""
|
||||
"""Utility functions for alpine_bits_python."""
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""Entry point for util package."""
|
||||
|
||||
from .handshake_util import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
from ..generated.alpinebits import OtaPingRq, OtaPingRs
|
||||
from xsdata_pydantic.bindings import XmlParser
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
# test parsing a ping request sample
|
||||
|
||||
path = "AlpineBits-HotelData-2024-10/files/samples/Handshake/Handshake-OTA_PingRS.xml"
|
||||
|
||||
with open(
|
||||
path, "r", encoding="utf-8") as f:
|
||||
xml = f.read()
|
||||
|
||||
# Parse the XML into the request object
|
||||
|
||||
# Test parsing back
|
||||
|
||||
|
||||
parser = XmlParser()
|
||||
|
||||
|
||||
|
||||
parsed_result = parser.from_string(xml, OtaPingRs)
|
||||
|
||||
print(parsed_result.echo_data)
|
||||
|
||||
warning = parsed_result.warnings.warning[0]
|
||||
|
||||
print(warning.type_value)
|
||||
|
||||
print(type(warning.content))
|
||||
|
||||
print(warning.content[0])
|
||||
|
||||
|
||||
|
||||
|
||||
# save json in echo_data to file with indents
|
||||
output_path = "echo_data_response.json"
|
||||
with open(output_path, "w", encoding="utf-8") as out_f:
|
||||
import json
|
||||
json.dump(json.loads(parsed_result.echo_data), out_f, indent=4)
|
||||
print(f"Saved echo_data json to {output_path}")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
||||
main()
|
||||
12
start_api.py
Normal file
12
start_api.py
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Convenience launcher for the Wix Form Handler API."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
# Change to src directory
|
||||
src_dir = os.path.join(os.path.dirname(__file__), "src/alpine_bits_python")
|
||||
|
||||
# Run the API using uv
|
||||
if __name__ == "__main__":
|
||||
subprocess.run(["uv", "run", "python", os.path.join(src_dir, "run_api.py")], check=False)
|
||||
@@ -1,61 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Quick test to demonstrate how the ServerCapabilities automatically
|
||||
discovers implemented vs unimplemented actions.
|
||||
"""
|
||||
|
||||
from alpine_bits_python.alpinebits_server import (
|
||||
ServerCapabilities,
|
||||
AlpineBitsAction,
|
||||
AlpineBitsActionName,
|
||||
Version,
|
||||
AlpineBitsResponse,
|
||||
HttpStatusCode
|
||||
)
|
||||
import asyncio
|
||||
|
||||
class NewImplementedAction(AlpineBitsAction):
|
||||
"""A new action that IS implemented."""
|
||||
|
||||
def __init__(self):
|
||||
self.name = AlpineBitsActionName.OTA_HOTEL_DESCRIPTIVE_INFO_INFO
|
||||
self.version = Version.V2024_10
|
||||
|
||||
async def handle(self, action: str, request_xml: str, version: Version) -> AlpineBitsResponse:
|
||||
"""This action is implemented."""
|
||||
return AlpineBitsResponse("Implemented!", HttpStatusCode.OK)
|
||||
|
||||
class NewUnimplementedAction(AlpineBitsAction):
|
||||
"""A new action that is NOT implemented (no handle override)."""
|
||||
|
||||
def __init__(self):
|
||||
self.name = AlpineBitsActionName.OTA_HOTEL_DESCRIPTIVE_CONTENT_NOTIF_INFO
|
||||
self.version = Version.V2024_10
|
||||
|
||||
# Notice: No handle method override - will use default "not implemented"
|
||||
|
||||
async def main():
|
||||
print("🔍 Testing Action Discovery Logic")
|
||||
print("=" * 50)
|
||||
|
||||
# Create capabilities and see what gets discovered
|
||||
capabilities = ServerCapabilities()
|
||||
|
||||
print("📋 Actions found by discovery:")
|
||||
for action_name in capabilities.get_supported_actions():
|
||||
print(f" ✅ {action_name}")
|
||||
|
||||
print(f"\n📊 Total discovered: {len(capabilities.get_supported_actions())}")
|
||||
|
||||
# Test the new implemented action
|
||||
implemented_action = NewImplementedAction()
|
||||
result = await implemented_action.handle("test", "<xml/>", Version.V2024_10)
|
||||
print(f"\n🟢 NewImplementedAction result: {result.xml_content}")
|
||||
|
||||
# Test the unimplemented action (should use default behavior)
|
||||
unimplemented_action = NewUnimplementedAction()
|
||||
result = await unimplemented_action.handle("test", "<xml/>", Version.V2024_10)
|
||||
print(f"🔴 NewUnimplementedAction result: {result.xml_content}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -1,29 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test the handshake functionality with the real AlpineBits sample file.
|
||||
"""
|
||||
"""Test the handshake functionality with the real AlpineBits sample file."""
|
||||
|
||||
import asyncio
|
||||
|
||||
from alpine_bits_python.alpinebits_server import AlpineBitsServer
|
||||
|
||||
|
||||
async def main():
|
||||
print("🔄 Testing AlpineBits Handshake with Sample File")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
# Create server instance
|
||||
server = AlpineBitsServer()
|
||||
|
||||
|
||||
# Read the sample handshake request
|
||||
with open("AlpineBits-HotelData-2024-10/files/samples/Handshake/Handshake-OTA_PingRQ.xml", "r") as f:
|
||||
with open(
|
||||
"AlpineBits-HotelData-2024-10/files/samples/Handshake/Handshake-OTA_PingRQ.xml",
|
||||
) as f:
|
||||
ping_request_xml = f.read()
|
||||
|
||||
print("📤 Sending handshake request...")
|
||||
|
||||
|
||||
|
||||
# Handle the ping request
|
||||
response = await server.handle_request("OTA_Ping:Handshaking", ping_request_xml, "2024-10")
|
||||
|
||||
print(f"\n📥 Response Status: {response.status_code}")
|
||||
print(f"📄 Response XML:\n{response.xml_content}")
|
||||
await server.handle_request(
|
||||
"OTA_Ping:Handshaking", ping_request_xml, "2024-10"
|
||||
)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
asyncio.run(main())
|
||||
|
||||
@@ -1,26 +1,20 @@
|
||||
import pytest
|
||||
from typing import Union
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Add the src directory to the path so we can import our modules
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
||||
|
||||
from simplified_access import (
|
||||
CustomerData,
|
||||
CustomerFactory,
|
||||
ResGuestFactory,
|
||||
from alpine_bits_python.alpine_bits_helpers import (
|
||||
AlpineBitsFactory,
|
||||
CustomerData,
|
||||
CustomerFactory,
|
||||
HotelReservationIdData,
|
||||
HotelReservationIdFactory,
|
||||
AlpineBitsFactory,
|
||||
PhoneTechType,
|
||||
OtaMessageType,
|
||||
NotifCustomer,
|
||||
RetrieveCustomer,
|
||||
NotifResGuests,
|
||||
RetrieveResGuests,
|
||||
NotifHotelReservationId,
|
||||
RetrieveHotelReservationId
|
||||
NotifResGuests,
|
||||
OtaMessageType,
|
||||
PhoneTechType,
|
||||
ResGuestFactory,
|
||||
RetrieveCustomer,
|
||||
RetrieveHotelReservationId,
|
||||
RetrieveResGuests,
|
||||
)
|
||||
|
||||
|
||||
@@ -35,7 +29,7 @@ def sample_customer_data():
|
||||
phone_numbers=[
|
||||
("+1234567890", PhoneTechType.MOBILE),
|
||||
("+0987654321", PhoneTechType.VOICE),
|
||||
("+1111111111", None)
|
||||
("+1111111111", None),
|
||||
],
|
||||
email_address="john.doe@example.com",
|
||||
email_newsletter=True,
|
||||
@@ -46,17 +40,14 @@ def sample_customer_data():
|
||||
address_catalog=False,
|
||||
gender="Male",
|
||||
birth_date="1980-01-01",
|
||||
language="en"
|
||||
language="en",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def minimal_customer_data():
|
||||
"""Fixture providing minimal customer data (only required fields)."""
|
||||
return CustomerData(
|
||||
given_name="Jane",
|
||||
surname="Smith"
|
||||
)
|
||||
return CustomerData(given_name="Jane", surname="Smith")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -66,21 +57,19 @@ def sample_hotel_reservation_id_data():
|
||||
res_id_type="123",
|
||||
res_id_value="RESERVATION-456",
|
||||
res_id_source="HOTEL_SYSTEM",
|
||||
res_id_source_context="BOOKING_ENGINE"
|
||||
res_id_source_context="BOOKING_ENGINE",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def minimal_hotel_reservation_id_data():
|
||||
"""Fixture providing minimal hotel reservation ID data (only required fields)."""
|
||||
return HotelReservationIdData(
|
||||
res_id_type="999"
|
||||
)
|
||||
return HotelReservationIdData(res_id_type="999")
|
||||
|
||||
|
||||
class TestCustomerData:
|
||||
"""Test the CustomerData dataclass."""
|
||||
|
||||
|
||||
def test_customer_data_creation_full(self, sample_customer_data):
|
||||
"""Test creating CustomerData with all fields."""
|
||||
assert sample_customer_data.given_name == "John"
|
||||
@@ -89,7 +78,7 @@ class TestCustomerData:
|
||||
assert sample_customer_data.email_address == "john.doe@example.com"
|
||||
assert sample_customer_data.email_newsletter is True
|
||||
assert len(sample_customer_data.phone_numbers) == 3
|
||||
|
||||
|
||||
def test_customer_data_creation_minimal(self, minimal_customer_data):
|
||||
"""Test creating CustomerData with only required fields."""
|
||||
assert minimal_customer_data.given_name == "Jane"
|
||||
@@ -97,7 +86,7 @@ class TestCustomerData:
|
||||
assert minimal_customer_data.phone_numbers == []
|
||||
assert minimal_customer_data.email_address is None
|
||||
assert minimal_customer_data.address_line is None
|
||||
|
||||
|
||||
def test_phone_numbers_default_initialization(self):
|
||||
"""Test that phone_numbers gets initialized to empty list."""
|
||||
customer_data = CustomerData(given_name="Test", surname="User")
|
||||
@@ -106,54 +95,56 @@ class TestCustomerData:
|
||||
|
||||
class TestCustomerFactory:
|
||||
"""Test the CustomerFactory class."""
|
||||
|
||||
|
||||
def test_create_notif_customer_full(self, sample_customer_data):
|
||||
"""Test creating a NotifCustomer with full data."""
|
||||
customer = CustomerFactory.create_notif_customer(sample_customer_data)
|
||||
|
||||
|
||||
assert isinstance(customer, NotifCustomer)
|
||||
assert customer.person_name.given_name == "John"
|
||||
assert customer.person_name.surname == "Doe"
|
||||
assert customer.person_name.name_prefix == "Mr."
|
||||
assert customer.person_name.name_title == "Jr."
|
||||
|
||||
|
||||
# Check telephone
|
||||
assert len(customer.telephone) == 3
|
||||
assert customer.telephone[0].phone_number == "+1234567890"
|
||||
assert customer.telephone[0].phone_tech_type == "5" # MOBILE
|
||||
assert customer.telephone[1].phone_tech_type == "1" # VOICE
|
||||
assert customer.telephone[2].phone_tech_type is None
|
||||
|
||||
|
||||
# Check email
|
||||
assert customer.email.value == "john.doe@example.com"
|
||||
assert customer.email.remark == "newsletter:yes"
|
||||
|
||||
|
||||
# Check address
|
||||
assert customer.address.address_line == "123 Main Street"
|
||||
assert customer.address.city_name == "Anytown"
|
||||
assert customer.address.postal_code == "12345"
|
||||
assert customer.address.country_name.code == "US"
|
||||
assert customer.address.remark == "catalog:no"
|
||||
|
||||
|
||||
# Check other attributes
|
||||
assert customer.gender == "Male"
|
||||
assert customer.birth_date == "1980-01-01"
|
||||
assert customer.language == "en"
|
||||
|
||||
|
||||
def test_create_retrieve_customer_full(self, sample_customer_data):
|
||||
"""Test creating a RetrieveCustomer with full data."""
|
||||
customer = CustomerFactory.create_retrieve_customer(sample_customer_data)
|
||||
|
||||
|
||||
assert isinstance(customer, RetrieveCustomer)
|
||||
assert customer.person_name.given_name == "John"
|
||||
assert customer.person_name.surname == "Doe"
|
||||
# Same structure as NotifCustomer, so we don't need to test all fields again
|
||||
|
||||
|
||||
def test_create_customer_minimal(self, minimal_customer_data):
|
||||
"""Test creating customers with minimal data."""
|
||||
notif_customer = CustomerFactory.create_notif_customer(minimal_customer_data)
|
||||
retrieve_customer = CustomerFactory.create_retrieve_customer(minimal_customer_data)
|
||||
|
||||
retrieve_customer = CustomerFactory.create_retrieve_customer(
|
||||
minimal_customer_data
|
||||
)
|
||||
|
||||
for customer in [notif_customer, retrieve_customer]:
|
||||
assert customer.person_name.given_name == "Jane"
|
||||
assert customer.person_name.surname == "Smith"
|
||||
@@ -165,73 +156,97 @@ class TestCustomerFactory:
|
||||
assert customer.gender is None
|
||||
assert customer.birth_date is None
|
||||
assert customer.language is None
|
||||
|
||||
|
||||
def test_email_newsletter_options(self):
|
||||
"""Test different email newsletter options."""
|
||||
# Newsletter yes
|
||||
data_yes = CustomerData(given_name="Test", surname="User",
|
||||
email_address="test@example.com", email_newsletter=True)
|
||||
data_yes = CustomerData(
|
||||
given_name="Test",
|
||||
surname="User",
|
||||
email_address="test@example.com",
|
||||
email_newsletter=True,
|
||||
)
|
||||
customer = CustomerFactory.create_notif_customer(data_yes)
|
||||
assert customer.email.remark == "newsletter:yes"
|
||||
|
||||
|
||||
# Newsletter no
|
||||
data_no = CustomerData(given_name="Test", surname="User",
|
||||
email_address="test@example.com", email_newsletter=False)
|
||||
data_no = CustomerData(
|
||||
given_name="Test",
|
||||
surname="User",
|
||||
email_address="test@example.com",
|
||||
email_newsletter=False,
|
||||
)
|
||||
customer = CustomerFactory.create_notif_customer(data_no)
|
||||
assert customer.email.remark == "newsletter:no"
|
||||
|
||||
|
||||
# Newsletter not specified
|
||||
data_none = CustomerData(given_name="Test", surname="User",
|
||||
email_address="test@example.com", email_newsletter=None)
|
||||
data_none = CustomerData(
|
||||
given_name="Test",
|
||||
surname="User",
|
||||
email_address="test@example.com",
|
||||
email_newsletter=None,
|
||||
)
|
||||
customer = CustomerFactory.create_notif_customer(data_none)
|
||||
assert customer.email.remark is None
|
||||
|
||||
|
||||
def test_address_catalog_options(self):
|
||||
"""Test different address catalog options."""
|
||||
# Catalog no
|
||||
data_no = CustomerData(given_name="Test", surname="User",
|
||||
address_line="123 Street", address_catalog=False)
|
||||
data_no = CustomerData(
|
||||
given_name="Test",
|
||||
surname="User",
|
||||
address_line="123 Street",
|
||||
address_catalog=False,
|
||||
)
|
||||
customer = CustomerFactory.create_notif_customer(data_no)
|
||||
assert customer.address.remark == "catalog:no"
|
||||
|
||||
|
||||
# Catalog yes
|
||||
data_yes = CustomerData(given_name="Test", surname="User",
|
||||
address_line="123 Street", address_catalog=True)
|
||||
data_yes = CustomerData(
|
||||
given_name="Test",
|
||||
surname="User",
|
||||
address_line="123 Street",
|
||||
address_catalog=True,
|
||||
)
|
||||
customer = CustomerFactory.create_notif_customer(data_yes)
|
||||
assert customer.address.remark == "catalog:yes"
|
||||
|
||||
|
||||
# Catalog not specified
|
||||
data_none = CustomerData(given_name="Test", surname="User",
|
||||
address_line="123 Street", address_catalog=None)
|
||||
data_none = CustomerData(
|
||||
given_name="Test",
|
||||
surname="User",
|
||||
address_line="123 Street",
|
||||
address_catalog=None,
|
||||
)
|
||||
customer = CustomerFactory.create_notif_customer(data_none)
|
||||
assert customer.address.remark is None
|
||||
|
||||
|
||||
def test_from_notif_customer_roundtrip(self, sample_customer_data):
|
||||
"""Test converting NotifCustomer back to CustomerData."""
|
||||
customer = CustomerFactory.create_notif_customer(sample_customer_data)
|
||||
converted_data = CustomerFactory.from_notif_customer(customer)
|
||||
|
||||
|
||||
assert converted_data == sample_customer_data
|
||||
|
||||
|
||||
def test_from_retrieve_customer_roundtrip(self, sample_customer_data):
|
||||
"""Test converting RetrieveCustomer back to CustomerData."""
|
||||
customer = CustomerFactory.create_retrieve_customer(sample_customer_data)
|
||||
converted_data = CustomerFactory.from_retrieve_customer(customer)
|
||||
|
||||
|
||||
assert converted_data == sample_customer_data
|
||||
|
||||
|
||||
def test_phone_tech_type_conversion(self):
|
||||
"""Test that PhoneTechType enum values are properly converted."""
|
||||
data = CustomerData(
|
||||
given_name="Test",
|
||||
given_name="Test",
|
||||
surname="User",
|
||||
phone_numbers=[
|
||||
("+1111111111", PhoneTechType.VOICE),
|
||||
("+2222222222", PhoneTechType.FAX),
|
||||
("+3333333333", PhoneTechType.MOBILE)
|
||||
]
|
||||
("+3333333333", PhoneTechType.MOBILE),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
customer = CustomerFactory.create_notif_customer(data)
|
||||
assert customer.telephone[0].phone_tech_type == "1" # VOICE
|
||||
assert customer.telephone[1].phone_tech_type == "3" # FAX
|
||||
@@ -240,15 +255,21 @@ class TestCustomerFactory:
|
||||
|
||||
class TestHotelReservationIdData:
|
||||
"""Test the HotelReservationIdData dataclass."""
|
||||
|
||||
def test_hotel_reservation_id_data_creation_full(self, sample_hotel_reservation_id_data):
|
||||
|
||||
def test_hotel_reservation_id_data_creation_full(
|
||||
self, sample_hotel_reservation_id_data
|
||||
):
|
||||
"""Test creating HotelReservationIdData with all fields."""
|
||||
assert sample_hotel_reservation_id_data.res_id_type == "123"
|
||||
assert sample_hotel_reservation_id_data.res_id_value == "RESERVATION-456"
|
||||
assert sample_hotel_reservation_id_data.res_id_source == "HOTEL_SYSTEM"
|
||||
assert sample_hotel_reservation_id_data.res_id_source_context == "BOOKING_ENGINE"
|
||||
|
||||
def test_hotel_reservation_id_data_creation_minimal(self, minimal_hotel_reservation_id_data):
|
||||
assert (
|
||||
sample_hotel_reservation_id_data.res_id_source_context == "BOOKING_ENGINE"
|
||||
)
|
||||
|
||||
def test_hotel_reservation_id_data_creation_minimal(
|
||||
self, minimal_hotel_reservation_id_data
|
||||
):
|
||||
"""Test creating HotelReservationIdData with only required fields."""
|
||||
assert minimal_hotel_reservation_id_data.res_id_type == "999"
|
||||
assert minimal_hotel_reservation_id_data.res_id_value is None
|
||||
@@ -258,124 +279,158 @@ class TestHotelReservationIdData:
|
||||
|
||||
class TestHotelReservationIdFactory:
|
||||
"""Test the HotelReservationIdFactory class."""
|
||||
|
||||
def test_create_notif_hotel_reservation_id_full(self, sample_hotel_reservation_id_data):
|
||||
|
||||
def test_create_notif_hotel_reservation_id_full(
|
||||
self, sample_hotel_reservation_id_data
|
||||
):
|
||||
"""Test creating a NotifHotelReservationId with full data."""
|
||||
reservation_id = HotelReservationIdFactory.create_notif_hotel_reservation_id(sample_hotel_reservation_id_data)
|
||||
|
||||
reservation_id = HotelReservationIdFactory.create_notif_hotel_reservation_id(
|
||||
sample_hotel_reservation_id_data
|
||||
)
|
||||
|
||||
assert isinstance(reservation_id, NotifHotelReservationId)
|
||||
assert reservation_id.res_id_type == "123"
|
||||
assert reservation_id.res_id_value == "RESERVATION-456"
|
||||
assert reservation_id.res_id_source == "HOTEL_SYSTEM"
|
||||
assert reservation_id.res_id_source_context == "BOOKING_ENGINE"
|
||||
|
||||
def test_create_retrieve_hotel_reservation_id_full(self, sample_hotel_reservation_id_data):
|
||||
|
||||
def test_create_retrieve_hotel_reservation_id_full(
|
||||
self, sample_hotel_reservation_id_data
|
||||
):
|
||||
"""Test creating a RetrieveHotelReservationId with full data."""
|
||||
reservation_id = HotelReservationIdFactory.create_retrieve_hotel_reservation_id(sample_hotel_reservation_id_data)
|
||||
|
||||
reservation_id = HotelReservationIdFactory.create_retrieve_hotel_reservation_id(
|
||||
sample_hotel_reservation_id_data
|
||||
)
|
||||
|
||||
assert isinstance(reservation_id, RetrieveHotelReservationId)
|
||||
assert reservation_id.res_id_type == "123"
|
||||
assert reservation_id.res_id_value == "RESERVATION-456"
|
||||
assert reservation_id.res_id_source == "HOTEL_SYSTEM"
|
||||
assert reservation_id.res_id_source_context == "BOOKING_ENGINE"
|
||||
|
||||
def test_create_hotel_reservation_id_minimal(self, minimal_hotel_reservation_id_data):
|
||||
|
||||
def test_create_hotel_reservation_id_minimal(
|
||||
self, minimal_hotel_reservation_id_data
|
||||
):
|
||||
"""Test creating hotel reservation IDs with minimal data."""
|
||||
notif_reservation_id = HotelReservationIdFactory.create_notif_hotel_reservation_id(minimal_hotel_reservation_id_data)
|
||||
retrieve_reservation_id = HotelReservationIdFactory.create_retrieve_hotel_reservation_id(minimal_hotel_reservation_id_data)
|
||||
|
||||
notif_reservation_id = (
|
||||
HotelReservationIdFactory.create_notif_hotel_reservation_id(
|
||||
minimal_hotel_reservation_id_data
|
||||
)
|
||||
)
|
||||
retrieve_reservation_id = (
|
||||
HotelReservationIdFactory.create_retrieve_hotel_reservation_id(
|
||||
minimal_hotel_reservation_id_data
|
||||
)
|
||||
)
|
||||
|
||||
for reservation_id in [notif_reservation_id, retrieve_reservation_id]:
|
||||
assert reservation_id.res_id_type == "999"
|
||||
assert reservation_id.res_id_value is None
|
||||
assert reservation_id.res_id_source is None
|
||||
assert reservation_id.res_id_source_context is None
|
||||
|
||||
def test_from_notif_hotel_reservation_id_roundtrip(self, sample_hotel_reservation_id_data):
|
||||
|
||||
def test_from_notif_hotel_reservation_id_roundtrip(
|
||||
self, sample_hotel_reservation_id_data
|
||||
):
|
||||
"""Test converting NotifHotelReservationId back to HotelReservationIdData."""
|
||||
reservation_id = HotelReservationIdFactory.create_notif_hotel_reservation_id(sample_hotel_reservation_id_data)
|
||||
converted_data = HotelReservationIdFactory.from_notif_hotel_reservation_id(reservation_id)
|
||||
|
||||
reservation_id = HotelReservationIdFactory.create_notif_hotel_reservation_id(
|
||||
sample_hotel_reservation_id_data
|
||||
)
|
||||
converted_data = HotelReservationIdFactory.from_notif_hotel_reservation_id(
|
||||
reservation_id
|
||||
)
|
||||
|
||||
assert converted_data == sample_hotel_reservation_id_data
|
||||
|
||||
def test_from_retrieve_hotel_reservation_id_roundtrip(self, sample_hotel_reservation_id_data):
|
||||
|
||||
def test_from_retrieve_hotel_reservation_id_roundtrip(
|
||||
self, sample_hotel_reservation_id_data
|
||||
):
|
||||
"""Test converting RetrieveHotelReservationId back to HotelReservationIdData."""
|
||||
reservation_id = HotelReservationIdFactory.create_retrieve_hotel_reservation_id(sample_hotel_reservation_id_data)
|
||||
converted_data = HotelReservationIdFactory.from_retrieve_hotel_reservation_id(reservation_id)
|
||||
|
||||
reservation_id = HotelReservationIdFactory.create_retrieve_hotel_reservation_id(
|
||||
sample_hotel_reservation_id_data
|
||||
)
|
||||
converted_data = HotelReservationIdFactory.from_retrieve_hotel_reservation_id(
|
||||
reservation_id
|
||||
)
|
||||
|
||||
assert converted_data == sample_hotel_reservation_id_data
|
||||
|
||||
|
||||
class TestResGuestFactory:
|
||||
"""Test the ResGuestFactory class."""
|
||||
|
||||
|
||||
def test_create_notif_res_guests(self, sample_customer_data):
|
||||
"""Test creating NotifResGuests structure."""
|
||||
res_guests = ResGuestFactory.create_notif_res_guests(sample_customer_data)
|
||||
|
||||
|
||||
assert isinstance(res_guests, NotifResGuests)
|
||||
|
||||
|
||||
# Navigate down the nested structure
|
||||
customer = res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
assert customer.person_name.given_name == "John"
|
||||
assert customer.person_name.surname == "Doe"
|
||||
assert customer.email.value == "john.doe@example.com"
|
||||
|
||||
|
||||
def test_create_retrieve_res_guests(self, sample_customer_data):
|
||||
"""Test creating RetrieveResGuests structure."""
|
||||
res_guests = ResGuestFactory.create_retrieve_res_guests(sample_customer_data)
|
||||
|
||||
|
||||
assert isinstance(res_guests, RetrieveResGuests)
|
||||
|
||||
|
||||
# Navigate down the nested structure
|
||||
customer = res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
assert customer.person_name.given_name == "John"
|
||||
assert customer.person_name.surname == "Doe"
|
||||
assert customer.email.value == "john.doe@example.com"
|
||||
|
||||
|
||||
def test_create_res_guests_minimal(self, minimal_customer_data):
|
||||
"""Test creating ResGuests with minimal customer data."""
|
||||
notif_res_guests = ResGuestFactory.create_notif_res_guests(minimal_customer_data)
|
||||
retrieve_res_guests = ResGuestFactory.create_retrieve_res_guests(minimal_customer_data)
|
||||
|
||||
notif_res_guests = ResGuestFactory.create_notif_res_guests(
|
||||
minimal_customer_data
|
||||
)
|
||||
retrieve_res_guests = ResGuestFactory.create_retrieve_res_guests(
|
||||
minimal_customer_data
|
||||
)
|
||||
|
||||
for res_guests in [notif_res_guests, retrieve_res_guests]:
|
||||
customer = res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
assert customer.person_name.given_name == "Jane"
|
||||
assert customer.person_name.surname == "Smith"
|
||||
assert customer.email is None
|
||||
assert customer.address is None
|
||||
|
||||
|
||||
def test_extract_primary_customer_notif(self, sample_customer_data):
|
||||
"""Test extracting primary customer from NotifResGuests."""
|
||||
res_guests = ResGuestFactory.create_notif_res_guests(sample_customer_data)
|
||||
extracted_data = ResGuestFactory.extract_primary_customer(res_guests)
|
||||
|
||||
|
||||
assert extracted_data == sample_customer_data
|
||||
|
||||
|
||||
def test_extract_primary_customer_retrieve(self, sample_customer_data):
|
||||
"""Test extracting primary customer from RetrieveResGuests."""
|
||||
res_guests = ResGuestFactory.create_retrieve_res_guests(sample_customer_data)
|
||||
extracted_data = ResGuestFactory.extract_primary_customer(res_guests)
|
||||
|
||||
|
||||
assert extracted_data == sample_customer_data
|
||||
|
||||
|
||||
def test_roundtrip_conversion_notif(self, sample_customer_data):
|
||||
"""Test complete roundtrip: CustomerData -> NotifResGuests -> CustomerData."""
|
||||
res_guests = ResGuestFactory.create_notif_res_guests(sample_customer_data)
|
||||
extracted_data = ResGuestFactory.extract_primary_customer(res_guests)
|
||||
|
||||
|
||||
assert extracted_data == sample_customer_data
|
||||
|
||||
|
||||
def test_roundtrip_conversion_retrieve(self, sample_customer_data):
|
||||
"""Test complete roundtrip: CustomerData -> RetrieveResGuests -> CustomerData."""
|
||||
res_guests = ResGuestFactory.create_retrieve_res_guests(sample_customer_data)
|
||||
extracted_data = ResGuestFactory.extract_primary_customer(res_guests)
|
||||
|
||||
|
||||
assert extracted_data == sample_customer_data
|
||||
|
||||
|
||||
class TestPhoneTechType:
|
||||
"""Test the PhoneTechType enum."""
|
||||
|
||||
|
||||
def test_enum_values(self):
|
||||
"""Test that enum values are correct."""
|
||||
assert PhoneTechType.VOICE.value == "1"
|
||||
@@ -385,95 +440,121 @@ class TestPhoneTechType:
|
||||
|
||||
class TestAlpineBitsFactory:
|
||||
"""Test the unified AlpineBitsFactory class."""
|
||||
|
||||
|
||||
def test_create_customer_notif(self, sample_customer_data):
|
||||
"""Test creating customer using unified factory for NOTIF."""
|
||||
customer = AlpineBitsFactory.create(sample_customer_data, OtaMessageType.NOTIF)
|
||||
assert isinstance(customer, NotifCustomer)
|
||||
assert customer.person_name.given_name == "John"
|
||||
assert customer.person_name.surname == "Doe"
|
||||
|
||||
|
||||
def test_create_customer_retrieve(self, sample_customer_data):
|
||||
"""Test creating customer using unified factory for RETRIEVE."""
|
||||
customer = AlpineBitsFactory.create(sample_customer_data, OtaMessageType.RETRIEVE)
|
||||
customer = AlpineBitsFactory.create(
|
||||
sample_customer_data, OtaMessageType.RETRIEVE
|
||||
)
|
||||
assert isinstance(customer, RetrieveCustomer)
|
||||
assert customer.person_name.given_name == "John"
|
||||
assert customer.person_name.surname == "Doe"
|
||||
|
||||
|
||||
def test_create_hotel_reservation_id_notif(self, sample_hotel_reservation_id_data):
|
||||
"""Test creating hotel reservation ID using unified factory for NOTIF."""
|
||||
reservation_id = AlpineBitsFactory.create(sample_hotel_reservation_id_data, OtaMessageType.NOTIF)
|
||||
reservation_id = AlpineBitsFactory.create(
|
||||
sample_hotel_reservation_id_data, OtaMessageType.NOTIF
|
||||
)
|
||||
assert isinstance(reservation_id, NotifHotelReservationId)
|
||||
assert reservation_id.res_id_type == "123"
|
||||
assert reservation_id.res_id_value == "RESERVATION-456"
|
||||
|
||||
def test_create_hotel_reservation_id_retrieve(self, sample_hotel_reservation_id_data):
|
||||
|
||||
def test_create_hotel_reservation_id_retrieve(
|
||||
self, sample_hotel_reservation_id_data
|
||||
):
|
||||
"""Test creating hotel reservation ID using unified factory for RETRIEVE."""
|
||||
reservation_id = AlpineBitsFactory.create(sample_hotel_reservation_id_data, OtaMessageType.RETRIEVE)
|
||||
reservation_id = AlpineBitsFactory.create(
|
||||
sample_hotel_reservation_id_data, OtaMessageType.RETRIEVE
|
||||
)
|
||||
assert isinstance(reservation_id, RetrieveHotelReservationId)
|
||||
assert reservation_id.res_id_type == "123"
|
||||
assert reservation_id.res_id_value == "RESERVATION-456"
|
||||
|
||||
|
||||
def test_create_res_guests_notif(self, sample_customer_data):
|
||||
"""Test creating ResGuests using unified factory for NOTIF."""
|
||||
res_guests = AlpineBitsFactory.create_res_guests(sample_customer_data, OtaMessageType.NOTIF)
|
||||
res_guests = AlpineBitsFactory.create_res_guests(
|
||||
sample_customer_data, OtaMessageType.NOTIF
|
||||
)
|
||||
assert isinstance(res_guests, NotifResGuests)
|
||||
customer = res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
assert customer.person_name.given_name == "John"
|
||||
|
||||
|
||||
def test_create_res_guests_retrieve(self, sample_customer_data):
|
||||
"""Test creating ResGuests using unified factory for RETRIEVE."""
|
||||
res_guests = AlpineBitsFactory.create_res_guests(sample_customer_data, OtaMessageType.RETRIEVE)
|
||||
res_guests = AlpineBitsFactory.create_res_guests(
|
||||
sample_customer_data, OtaMessageType.RETRIEVE
|
||||
)
|
||||
assert isinstance(res_guests, RetrieveResGuests)
|
||||
customer = res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
assert customer.person_name.given_name == "John"
|
||||
|
||||
|
||||
def test_extract_data_from_customer(self, sample_customer_data):
|
||||
"""Test extracting data from customer objects."""
|
||||
# Create both types and extract data back
|
||||
notif_customer = AlpineBitsFactory.create(sample_customer_data, OtaMessageType.NOTIF)
|
||||
retrieve_customer = AlpineBitsFactory.create(sample_customer_data, OtaMessageType.RETRIEVE)
|
||||
|
||||
notif_customer = AlpineBitsFactory.create(
|
||||
sample_customer_data, OtaMessageType.NOTIF
|
||||
)
|
||||
retrieve_customer = AlpineBitsFactory.create(
|
||||
sample_customer_data, OtaMessageType.RETRIEVE
|
||||
)
|
||||
|
||||
notif_extracted = AlpineBitsFactory.extract_data(notif_customer)
|
||||
retrieve_extracted = AlpineBitsFactory.extract_data(retrieve_customer)
|
||||
|
||||
|
||||
assert notif_extracted == sample_customer_data
|
||||
assert retrieve_extracted == sample_customer_data
|
||||
|
||||
def test_extract_data_from_hotel_reservation_id(self, sample_hotel_reservation_id_data):
|
||||
|
||||
def test_extract_data_from_hotel_reservation_id(
|
||||
self, sample_hotel_reservation_id_data
|
||||
):
|
||||
"""Test extracting data from hotel reservation ID objects."""
|
||||
# Create both types and extract data back
|
||||
notif_res_id = AlpineBitsFactory.create(sample_hotel_reservation_id_data, OtaMessageType.NOTIF)
|
||||
retrieve_res_id = AlpineBitsFactory.create(sample_hotel_reservation_id_data, OtaMessageType.RETRIEVE)
|
||||
|
||||
notif_res_id = AlpineBitsFactory.create(
|
||||
sample_hotel_reservation_id_data, OtaMessageType.NOTIF
|
||||
)
|
||||
retrieve_res_id = AlpineBitsFactory.create(
|
||||
sample_hotel_reservation_id_data, OtaMessageType.RETRIEVE
|
||||
)
|
||||
|
||||
notif_extracted = AlpineBitsFactory.extract_data(notif_res_id)
|
||||
retrieve_extracted = AlpineBitsFactory.extract_data(retrieve_res_id)
|
||||
|
||||
|
||||
assert notif_extracted == sample_hotel_reservation_id_data
|
||||
assert retrieve_extracted == sample_hotel_reservation_id_data
|
||||
|
||||
|
||||
def test_extract_data_from_res_guests(self, sample_customer_data):
|
||||
"""Test extracting data from ResGuests objects."""
|
||||
# Create both types and extract data back
|
||||
notif_res_guests = AlpineBitsFactory.create_res_guests(sample_customer_data, OtaMessageType.NOTIF)
|
||||
retrieve_res_guests = AlpineBitsFactory.create_res_guests(sample_customer_data, OtaMessageType.RETRIEVE)
|
||||
|
||||
notif_res_guests = AlpineBitsFactory.create_res_guests(
|
||||
sample_customer_data, OtaMessageType.NOTIF
|
||||
)
|
||||
retrieve_res_guests = AlpineBitsFactory.create_res_guests(
|
||||
sample_customer_data, OtaMessageType.RETRIEVE
|
||||
)
|
||||
|
||||
notif_extracted = AlpineBitsFactory.extract_data(notif_res_guests)
|
||||
retrieve_extracted = AlpineBitsFactory.extract_data(retrieve_res_guests)
|
||||
|
||||
|
||||
assert notif_extracted == sample_customer_data
|
||||
assert retrieve_extracted == sample_customer_data
|
||||
|
||||
|
||||
def test_unsupported_data_type_error(self):
|
||||
"""Test that unsupported data types raise ValueError."""
|
||||
with pytest.raises(ValueError, match="Unsupported data type"):
|
||||
AlpineBitsFactory.create("invalid_data", OtaMessageType.NOTIF)
|
||||
|
||||
|
||||
def test_unsupported_object_type_error(self):
|
||||
"""Test that unsupported object types raise ValueError in extract_data."""
|
||||
with pytest.raises(ValueError, match="Unsupported object type"):
|
||||
AlpineBitsFactory.extract_data("invalid_object")
|
||||
|
||||
|
||||
def test_complete_workflow_with_unified_factory(self):
|
||||
"""Test a complete workflow using only the unified factory."""
|
||||
# Original data
|
||||
@@ -481,34 +562,47 @@ class TestAlpineBitsFactory:
|
||||
given_name="Unified",
|
||||
surname="Factory",
|
||||
email_address="unified@factory.com",
|
||||
phone_numbers=[("+1234567890", PhoneTechType.MOBILE)]
|
||||
phone_numbers=[("+1234567890", PhoneTechType.MOBILE)],
|
||||
)
|
||||
|
||||
|
||||
reservation_data = HotelReservationIdData(
|
||||
res_id_type="999",
|
||||
res_id_value="UNIFIED-TEST"
|
||||
res_id_type="999", res_id_value="UNIFIED-TEST"
|
||||
)
|
||||
|
||||
|
||||
# Create using unified factory
|
||||
customer_notif = AlpineBitsFactory.create(customer_data, OtaMessageType.NOTIF)
|
||||
customer_retrieve = AlpineBitsFactory.create(customer_data, OtaMessageType.RETRIEVE)
|
||||
|
||||
customer_retrieve = AlpineBitsFactory.create(
|
||||
customer_data, OtaMessageType.RETRIEVE
|
||||
)
|
||||
|
||||
res_id_notif = AlpineBitsFactory.create(reservation_data, OtaMessageType.NOTIF)
|
||||
res_id_retrieve = AlpineBitsFactory.create(reservation_data, OtaMessageType.RETRIEVE)
|
||||
|
||||
res_guests_notif = AlpineBitsFactory.create_res_guests(customer_data, OtaMessageType.NOTIF)
|
||||
res_guests_retrieve = AlpineBitsFactory.create_res_guests(customer_data, OtaMessageType.RETRIEVE)
|
||||
|
||||
res_id_retrieve = AlpineBitsFactory.create(
|
||||
reservation_data, OtaMessageType.RETRIEVE
|
||||
)
|
||||
|
||||
res_guests_notif = AlpineBitsFactory.create_res_guests(
|
||||
customer_data, OtaMessageType.NOTIF
|
||||
)
|
||||
res_guests_retrieve = AlpineBitsFactory.create_res_guests(
|
||||
customer_data, OtaMessageType.RETRIEVE
|
||||
)
|
||||
|
||||
# Extract everything back
|
||||
extracted_customer_from_notif = AlpineBitsFactory.extract_data(customer_notif)
|
||||
extracted_customer_from_retrieve = AlpineBitsFactory.extract_data(customer_retrieve)
|
||||
|
||||
extracted_customer_from_retrieve = AlpineBitsFactory.extract_data(
|
||||
customer_retrieve
|
||||
)
|
||||
|
||||
extracted_res_id_from_notif = AlpineBitsFactory.extract_data(res_id_notif)
|
||||
extracted_res_id_from_retrieve = AlpineBitsFactory.extract_data(res_id_retrieve)
|
||||
|
||||
extracted_from_res_guests_notif = AlpineBitsFactory.extract_data(res_guests_notif)
|
||||
extracted_from_res_guests_retrieve = AlpineBitsFactory.extract_data(res_guests_retrieve)
|
||||
|
||||
|
||||
extracted_from_res_guests_notif = AlpineBitsFactory.extract_data(
|
||||
res_guests_notif
|
||||
)
|
||||
extracted_from_res_guests_retrieve = AlpineBitsFactory.extract_data(
|
||||
res_guests_retrieve
|
||||
)
|
||||
|
||||
# Verify everything matches
|
||||
assert extracted_customer_from_notif == customer_data
|
||||
assert extracted_customer_from_retrieve == customer_data
|
||||
@@ -520,37 +614,72 @@ class TestAlpineBitsFactory:
|
||||
|
||||
class TestIntegration:
|
||||
"""Integration tests combining both factories."""
|
||||
|
||||
|
||||
def test_both_factories_produce_same_customer_data(self, sample_customer_data):
|
||||
"""Test that both factories can work with the same customer data."""
|
||||
# Create using CustomerFactory
|
||||
notif_customer = CustomerFactory.create_notif_customer(sample_customer_data)
|
||||
retrieve_customer = CustomerFactory.create_retrieve_customer(sample_customer_data)
|
||||
|
||||
retrieve_customer = CustomerFactory.create_retrieve_customer(
|
||||
sample_customer_data
|
||||
)
|
||||
|
||||
# Create using ResGuestFactory and extract customers
|
||||
notif_res_guests = ResGuestFactory.create_notif_res_guests(sample_customer_data)
|
||||
retrieve_res_guests = ResGuestFactory.create_retrieve_res_guests(sample_customer_data)
|
||||
|
||||
notif_from_res_guests = notif_res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
retrieve_from_res_guests = retrieve_res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
|
||||
retrieve_res_guests = ResGuestFactory.create_retrieve_res_guests(
|
||||
sample_customer_data
|
||||
)
|
||||
|
||||
notif_from_res_guests = (
|
||||
notif_res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
)
|
||||
retrieve_from_res_guests = (
|
||||
retrieve_res_guests.res_guest.profiles.profile_info.profile.customer
|
||||
)
|
||||
|
||||
# Compare customer names (structure should be identical)
|
||||
assert notif_customer.person_name.given_name == notif_from_res_guests.person_name.given_name
|
||||
assert notif_customer.person_name.surname == notif_from_res_guests.person_name.surname
|
||||
assert retrieve_customer.person_name.given_name == retrieve_from_res_guests.person_name.given_name
|
||||
assert retrieve_customer.person_name.surname == retrieve_from_res_guests.person_name.surname
|
||||
|
||||
def test_hotel_reservation_id_factories_produce_same_data(self, sample_hotel_reservation_id_data):
|
||||
assert (
|
||||
notif_customer.person_name.given_name
|
||||
== notif_from_res_guests.person_name.given_name
|
||||
)
|
||||
assert (
|
||||
notif_customer.person_name.surname
|
||||
== notif_from_res_guests.person_name.surname
|
||||
)
|
||||
assert (
|
||||
retrieve_customer.person_name.given_name
|
||||
== retrieve_from_res_guests.person_name.given_name
|
||||
)
|
||||
assert (
|
||||
retrieve_customer.person_name.surname
|
||||
== retrieve_from_res_guests.person_name.surname
|
||||
)
|
||||
|
||||
def test_hotel_reservation_id_factories_produce_same_data(
|
||||
self, sample_hotel_reservation_id_data
|
||||
):
|
||||
"""Test that both HotelReservationId factories produce equivalent results."""
|
||||
notif_reservation_id = HotelReservationIdFactory.create_notif_hotel_reservation_id(sample_hotel_reservation_id_data)
|
||||
retrieve_reservation_id = HotelReservationIdFactory.create_retrieve_hotel_reservation_id(sample_hotel_reservation_id_data)
|
||||
|
||||
notif_reservation_id = (
|
||||
HotelReservationIdFactory.create_notif_hotel_reservation_id(
|
||||
sample_hotel_reservation_id_data
|
||||
)
|
||||
)
|
||||
retrieve_reservation_id = (
|
||||
HotelReservationIdFactory.create_retrieve_hotel_reservation_id(
|
||||
sample_hotel_reservation_id_data
|
||||
)
|
||||
)
|
||||
|
||||
# Both should have the same field values
|
||||
assert notif_reservation_id.res_id_type == retrieve_reservation_id.res_id_type
|
||||
assert notif_reservation_id.res_id_value == retrieve_reservation_id.res_id_value
|
||||
assert notif_reservation_id.res_id_source == retrieve_reservation_id.res_id_source
|
||||
assert notif_reservation_id.res_id_source_context == retrieve_reservation_id.res_id_source_context
|
||||
|
||||
assert (
|
||||
notif_reservation_id.res_id_source == retrieve_reservation_id.res_id_source
|
||||
)
|
||||
assert (
|
||||
notif_reservation_id.res_id_source_context
|
||||
== retrieve_reservation_id.res_id_source_context
|
||||
)
|
||||
|
||||
def test_complex_customer_workflow(self):
|
||||
"""Test a complex workflow with multiple operations."""
|
||||
# Create original data
|
||||
@@ -559,7 +688,7 @@ class TestIntegration:
|
||||
surname="Johnson",
|
||||
phone_numbers=[
|
||||
("+1555123456", PhoneTechType.MOBILE),
|
||||
("+1555654321", PhoneTechType.VOICE)
|
||||
("+1555654321", PhoneTechType.VOICE),
|
||||
],
|
||||
email_address="alice.johnson@company.com",
|
||||
email_newsletter=False,
|
||||
@@ -569,22 +698,24 @@ class TestIntegration:
|
||||
country_code="CA",
|
||||
address_catalog=True,
|
||||
gender="Female",
|
||||
language="fr"
|
||||
language="fr",
|
||||
)
|
||||
|
||||
|
||||
# Create ResGuests for both types
|
||||
notif_res_guests = ResGuestFactory.create_notif_res_guests(original_data)
|
||||
retrieve_res_guests = ResGuestFactory.create_retrieve_res_guests(original_data)
|
||||
|
||||
|
||||
# Extract data back from both
|
||||
notif_extracted = ResGuestFactory.extract_primary_customer(notif_res_guests)
|
||||
retrieve_extracted = ResGuestFactory.extract_primary_customer(retrieve_res_guests)
|
||||
|
||||
retrieve_extracted = ResGuestFactory.extract_primary_customer(
|
||||
retrieve_res_guests
|
||||
)
|
||||
|
||||
# All should be equal
|
||||
assert original_data == notif_extracted
|
||||
assert original_data == retrieve_extracted
|
||||
assert notif_extracted == retrieve_extracted
|
||||
|
||||
|
||||
def test_complex_hotel_reservation_id_workflow(self):
|
||||
"""Test a complex workflow with HotelReservationId operations."""
|
||||
# Create original reservation ID data
|
||||
@@ -592,18 +723,30 @@ class TestIntegration:
|
||||
res_id_type="456",
|
||||
res_id_value="COMPLEX-RESERVATION-789",
|
||||
res_id_source="INTEGRATION_SYSTEM",
|
||||
res_id_source_context="API_CALL"
|
||||
res_id_source_context="API_CALL",
|
||||
)
|
||||
|
||||
|
||||
# Create HotelReservationId for both types
|
||||
notif_reservation_id = HotelReservationIdFactory.create_notif_hotel_reservation_id(original_data)
|
||||
retrieve_reservation_id = HotelReservationIdFactory.create_retrieve_hotel_reservation_id(original_data)
|
||||
|
||||
notif_reservation_id = (
|
||||
HotelReservationIdFactory.create_notif_hotel_reservation_id(original_data)
|
||||
)
|
||||
retrieve_reservation_id = (
|
||||
HotelReservationIdFactory.create_retrieve_hotel_reservation_id(
|
||||
original_data
|
||||
)
|
||||
)
|
||||
|
||||
# Extract data back from both
|
||||
notif_extracted = HotelReservationIdFactory.from_notif_hotel_reservation_id(notif_reservation_id)
|
||||
retrieve_extracted = HotelReservationIdFactory.from_retrieve_hotel_reservation_id(retrieve_reservation_id)
|
||||
|
||||
notif_extracted = HotelReservationIdFactory.from_notif_hotel_reservation_id(
|
||||
notif_reservation_id
|
||||
)
|
||||
retrieve_extracted = (
|
||||
HotelReservationIdFactory.from_retrieve_hotel_reservation_id(
|
||||
retrieve_reservation_id
|
||||
)
|
||||
)
|
||||
|
||||
# All should be equal
|
||||
assert original_data == notif_extracted
|
||||
assert original_data == retrieve_extracted
|
||||
assert notif_extracted == retrieve_extracted
|
||||
assert notif_extracted == retrieve_extracted
|
||||
0
tests/test_alpine_bits_server.py
Normal file
0
tests/test_alpine_bits_server.py
Normal file
952
tests/test_alpine_bits_server_read.py
Normal file
952
tests/test_alpine_bits_server_read.py
Normal file
@@ -0,0 +1,952 @@
|
||||
"""Tests for AlpineBits server read action.
|
||||
|
||||
This module tests the ReadAction handler which retrieves reservations
|
||||
from the database and returns them as OTA_ResRetrieveRS XML.
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
from datetime import UTC, date, datetime
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
||||
from xsdata.formats.dataclass.serializers.config import SerializerConfig
|
||||
from xsdata_pydantic.bindings import XmlParser, XmlSerializer
|
||||
|
||||
from alpine_bits_python.alpine_bits_helpers import create_res_retrieve_response
|
||||
from alpine_bits_python.alpinebits_server import AlpineBitsClientInfo, AlpineBitsServer
|
||||
from alpine_bits_python.db import AckedRequest, Base, Customer, Reservation
|
||||
from alpine_bits_python.generated import OtaReadRq
|
||||
from alpine_bits_python.generated.alpinebits import OtaResRetrieveRs
|
||||
from alpine_bits_python.schemas import ReservationData
|
||||
|
||||
# HTTP status code constants
|
||||
HTTP_OK = 200
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def test_db_engine():
|
||||
"""Create an in-memory SQLite database for testing."""
|
||||
engine = create_async_engine(
|
||||
"sqlite+aiosqlite:///:memory:",
|
||||
echo=False,
|
||||
)
|
||||
|
||||
# Create tables
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
|
||||
yield engine
|
||||
|
||||
# Cleanup
|
||||
await engine.dispose()
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def test_db_session(test_db_engine):
|
||||
"""Create a test database session."""
|
||||
async_session = async_sessionmaker(
|
||||
test_db_engine,
|
||||
class_=AsyncSession,
|
||||
expire_on_commit=False,
|
||||
)
|
||||
|
||||
async with async_session() as session:
|
||||
yield session
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_customer():
|
||||
"""Create a sample customer for testing."""
|
||||
return Customer(
|
||||
id=1,
|
||||
given_name="John",
|
||||
surname="Doe",
|
||||
contact_id="CONTACT-12345",
|
||||
name_prefix="Mr.",
|
||||
name_title="Jr.",
|
||||
email_address="john.doe@example.com",
|
||||
phone="+1234567890",
|
||||
email_newsletter=True,
|
||||
address_line="123 Main Street",
|
||||
city_name="Anytown",
|
||||
postal_code="12345",
|
||||
country_code="US",
|
||||
gender="Male",
|
||||
birth_date="1980-01-01",
|
||||
language="en",
|
||||
address_catalog=False,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_reservation(sample_customer):
|
||||
"""Create a sample reservation for testing."""
|
||||
reservation = ReservationData(
|
||||
unique_id="RES-2024-001",
|
||||
start_date=date(2024, 12, 25),
|
||||
end_date=date(2024, 12, 31),
|
||||
num_adults=2,
|
||||
num_children=1,
|
||||
children_ages=[8],
|
||||
offer="Christmas Special",
|
||||
created_at=datetime(2024, 11, 1, 12, 0, 0, tzinfo=UTC),
|
||||
utm_source="google",
|
||||
utm_medium="cpc",
|
||||
utm_campaign="winter2024",
|
||||
utm_term="ski resort",
|
||||
utm_content="ad1",
|
||||
user_comment="Late check-in requested",
|
||||
fbclid="PAZXh0bgNhZW0BMABhZGlkAasmYBTNE3QBp1jWuJ9zIpfEGRJMP63fMAMI405yvG5EtH-OT0PxSkAbBJaudFHR6cMtkdHu_aem_fopaFtECyVPNW9fmWfEkyA",
|
||||
gclid="",
|
||||
hotel_code="HOTEL123",
|
||||
hotel_name="Alpine Paradise Resort",
|
||||
)
|
||||
data = reservation.model_dump(exclude_none=True)
|
||||
|
||||
children_list = data.pop("children_ages", [])
|
||||
children_csv = ",".join(str(int(a)) for a in children_list) if children_list else ""
|
||||
data["children_ages"] = children_csv
|
||||
|
||||
return Reservation(
|
||||
id=1,
|
||||
customer_id=1,
|
||||
**data,
|
||||
customer=sample_customer,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def minimal_customer():
|
||||
"""Create a minimal customer with only required fields."""
|
||||
return Customer(
|
||||
id=2,
|
||||
given_name="Jane",
|
||||
surname="Smith",
|
||||
contact_id="CONTACT-67890",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def minimal_reservation(minimal_customer):
|
||||
"""Create a minimal reservation with only required fields."""
|
||||
reservation = ReservationData(
|
||||
unique_id="RES-2024-002",
|
||||
start_date=date(2025, 1, 15),
|
||||
end_date=date(2025, 1, 20),
|
||||
num_adults=1,
|
||||
num_children=0,
|
||||
children_ages=[],
|
||||
hotel_code="HOTEL123",
|
||||
created_at=datetime(2024, 12, 2, 12, 0, 0, tzinfo=UTC),
|
||||
hotel_name="Alpine Paradise Resort",
|
||||
)
|
||||
|
||||
data = reservation.model_dump(exclude_none=True)
|
||||
|
||||
children_list = data.pop("children_ages", [])
|
||||
children_csv = ",".join(str(int(a)) for a in children_list) if children_list else ""
|
||||
data["children_ages"] = children_csv
|
||||
|
||||
return Reservation(
|
||||
id=2,
|
||||
customer_id=2,
|
||||
**data,
|
||||
customer=minimal_customer,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def read_request_xml():
|
||||
"""Sample OTA_ReadRQ XML request."""
|
||||
return """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_ReadRQ xmlns="http://www.opentravel.org/OTA/2003/05"
|
||||
EchoToken="12345"
|
||||
TimeStamp="2024-10-07T10:00:00"
|
||||
Version="8.000">
|
||||
<ReadRequests>
|
||||
<HotelReadRequest HotelCode="HOTEL123" HotelName="Alpine Paradise Resort">
|
||||
<SelectionCriteria Start="2024-10-01" End="2025-01-31"/>
|
||||
</HotelReadRequest>
|
||||
</ReadRequests>
|
||||
</OTA_ReadRQ>"""
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def read_request_xml_no_date_filter():
|
||||
"""Sample OTA_ReadRQ XML request without date filter."""
|
||||
return """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_ReadRQ xmlns="http://www.opentravel.org/OTA/2003/05"
|
||||
EchoToken="12345"
|
||||
TimeStamp="2024-10-07T10:00:00"
|
||||
Version="8.000">
|
||||
<ReadRequests>
|
||||
<HotelReadRequest HotelCode="HOTEL123" HotelName="Alpine Paradise Resort"/>
|
||||
</ReadRequests>
|
||||
</OTA_ReadRQ>"""
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_config():
|
||||
"""Test configuration with hotel credentials."""
|
||||
return {
|
||||
"server": {
|
||||
"codecontext": "ADVERTISING",
|
||||
"code": "70597314",
|
||||
"companyname": "99tales Gmbh",
|
||||
"res_id_source_context": "99tales",
|
||||
},
|
||||
"alpine_bits_auth": [
|
||||
{
|
||||
"hotel_id": "HOTEL123",
|
||||
"hotel_name": "Alpine Paradise Resort",
|
||||
"username": "testuser",
|
||||
"password": "testpass",
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client_info():
|
||||
"""Sample client info for testing."""
|
||||
return AlpineBitsClientInfo(
|
||||
username="testuser",
|
||||
password="testpass",
|
||||
client_id="CLIENT-001",
|
||||
)
|
||||
|
||||
|
||||
class TestCreateResRetrieveResponse:
|
||||
"""Test the create_res_retrieve_response function."""
|
||||
|
||||
def test_empty_list(self, test_config):
|
||||
"""Test creating response with empty reservation list."""
|
||||
response = create_res_retrieve_response([], config=test_config)
|
||||
|
||||
assert response is not None, "Response should not be None"
|
||||
|
||||
# check that response is of correct type
|
||||
assert isinstance(response, OtaResRetrieveRs), (
|
||||
"Response should be of type OtaResRetrieveRs"
|
||||
)
|
||||
|
||||
assert hasattr(response, "success"), "Response should have success attribute"
|
||||
|
||||
assert hasattr(response, "reservations_list"), (
|
||||
"Response should have reservations_list attribute"
|
||||
)
|
||||
|
||||
def test_single_reservation(self, sample_reservation, sample_customer, test_config):
|
||||
"""Test creating response with single reservation."""
|
||||
reservation_pairs = [(sample_reservation, sample_customer)]
|
||||
response = create_res_retrieve_response(reservation_pairs, config=test_config)
|
||||
|
||||
assert response is not None
|
||||
assert hasattr(response, "reservations_list"), (
|
||||
"Response should have reservations_list attribute"
|
||||
)
|
||||
|
||||
assert hasattr(response.reservations_list, "hotel_reservation"), (
|
||||
"reservations_list should have reservation attribute"
|
||||
)
|
||||
|
||||
assert len(response.reservations_list.hotel_reservation) == 1
|
||||
res: OtaResRetrieveRs.ReservationsList.HotelReservation = (
|
||||
response.reservations_list.hotel_reservation[0]
|
||||
)
|
||||
|
||||
assert res.unique_id is not None, "Reservation should have unique_id"
|
||||
# Verify the response can be serialized to XML
|
||||
config = SerializerConfig(
|
||||
pretty_print=True, xml_declaration=True, encoding="UTF-8"
|
||||
)
|
||||
serializer = XmlSerializer(config=config)
|
||||
xml_output = serializer.render(
|
||||
response, ns_map={None: "http://www.opentravel.org/OTA/2003/05"}
|
||||
)
|
||||
|
||||
assert xml_output is not None
|
||||
# assert "RES-2024-001" in xml_output does not work due to hashing
|
||||
assert "John" in xml_output
|
||||
assert "Doe" in xml_output
|
||||
assert "HOTEL123" in xml_output
|
||||
|
||||
def test_multiple_reservations(
|
||||
self,
|
||||
sample_reservation,
|
||||
sample_customer,
|
||||
minimal_reservation,
|
||||
minimal_customer,
|
||||
test_config,
|
||||
):
|
||||
"""Test creating response with multiple reservations."""
|
||||
reservation_pairs = [
|
||||
(sample_reservation, sample_customer),
|
||||
(minimal_reservation, minimal_customer),
|
||||
]
|
||||
response = create_res_retrieve_response(reservation_pairs, config=test_config)
|
||||
|
||||
assert response is not None
|
||||
|
||||
# Serialize to XML and verify both reservations are present
|
||||
config = SerializerConfig(
|
||||
pretty_print=True, xml_declaration=True, encoding="UTF-8"
|
||||
)
|
||||
serializer = XmlSerializer(config=config)
|
||||
xml_output = serializer.render(
|
||||
response, ns_map={None: "http://www.opentravel.org/OTA/2003/05"}
|
||||
)
|
||||
|
||||
# assert "RES-2024-001" in xml_output
|
||||
# assert "RES-2024-002" in xml_output
|
||||
assert "John" in xml_output
|
||||
assert "Jane" in xml_output
|
||||
|
||||
def test_reservation_with_children(
|
||||
self, sample_reservation, sample_customer, test_config
|
||||
):
|
||||
"""Test reservation with children ages."""
|
||||
sample_reservation.num_children = 2
|
||||
sample_reservation.children_ages = "8,5"
|
||||
|
||||
reservation_pairs = [(sample_reservation, sample_customer)]
|
||||
response = create_res_retrieve_response(reservation_pairs, config=test_config)
|
||||
|
||||
config = SerializerConfig(pretty_print=True)
|
||||
serializer = XmlSerializer(config=config)
|
||||
xml_output = serializer.render(
|
||||
response, ns_map={None: "http://www.opentravel.org/OTA/2003/05"}
|
||||
)
|
||||
|
||||
assert response is not None
|
||||
# Children should be represented in guest counts
|
||||
assert "GuestCount" in xml_output or "Child" in xml_output
|
||||
|
||||
|
||||
class TestXMLParsing:
|
||||
"""Test XML parsing and generation."""
|
||||
|
||||
def test_parse_read_request(self, read_request_xml):
|
||||
"""Test parsing of OTA_ReadRQ XML."""
|
||||
parser = XmlParser()
|
||||
read_request = parser.from_string(read_request_xml, OtaReadRq)
|
||||
|
||||
assert read_request is not None
|
||||
assert read_request.read_requests is not None
|
||||
assert read_request.read_requests.hotel_read_request is not None
|
||||
|
||||
hotel_req = read_request.read_requests.hotel_read_request
|
||||
assert hotel_req.hotel_code == "HOTEL123"
|
||||
assert hotel_req.hotel_name == "Alpine Paradise Resort"
|
||||
assert hotel_req.selection_criteria is not None
|
||||
assert hotel_req.selection_criteria.start == "2024-10-01"
|
||||
|
||||
def test_parse_read_request_no_date(self, read_request_xml_no_date_filter):
|
||||
"""Test parsing of OTA_ReadRQ without date filter."""
|
||||
parser = XmlParser()
|
||||
read_request = parser.from_string(read_request_xml_no_date_filter, OtaReadRq)
|
||||
|
||||
assert read_request is not None
|
||||
hotel_req = read_request.read_requests.hotel_read_request
|
||||
assert hotel_req.hotel_code == "HOTEL123"
|
||||
assert hotel_req.selection_criteria is None
|
||||
|
||||
def test_serialize_retrieve_response(
|
||||
self,
|
||||
sample_reservation,
|
||||
sample_customer,
|
||||
test_config,
|
||||
):
|
||||
"""Test serialization of retrieve response to XML."""
|
||||
reservation_pairs = [(sample_reservation, sample_customer)]
|
||||
response = create_res_retrieve_response(reservation_pairs, config=test_config)
|
||||
|
||||
config = SerializerConfig(
|
||||
pretty_print=True, xml_declaration=True, encoding="UTF-8"
|
||||
)
|
||||
serializer = XmlSerializer(config=config)
|
||||
xml_output = serializer.render(
|
||||
response, ns_map={None: "http://www.opentravel.org/OTA/2003/05"}
|
||||
)
|
||||
|
||||
# Verify it's valid XML
|
||||
assert xml_output.startswith('<?xml version="1.0" encoding="UTF-8"?>')
|
||||
assert "OTA_ResRetrieveRS" in xml_output
|
||||
|
||||
# Verify customer data is present
|
||||
assert "John" in xml_output
|
||||
assert "Doe" in xml_output
|
||||
assert "john.doe@example.com" in xml_output
|
||||
|
||||
# Verify reservation data is present
|
||||
# assert "RES-2024-001" in xml_output
|
||||
assert "HOTEL123" in xml_output
|
||||
|
||||
|
||||
class TestEdgeCases:
|
||||
"""Test edge cases and error conditions."""
|
||||
|
||||
def test_customer_with_special_characters(self, test_config):
|
||||
"""Test customer with special characters in name."""
|
||||
customer = Customer(
|
||||
id=99,
|
||||
given_name="François",
|
||||
surname="O'Brien-Smith",
|
||||
contact_id="CONTACT-SPECIAL",
|
||||
)
|
||||
reservation = Reservation(
|
||||
id=99,
|
||||
customer_id=99,
|
||||
unique_id="RES-SPECIAL",
|
||||
start_date=date(2025, 1, 1),
|
||||
end_date=date(2025, 1, 5),
|
||||
num_adults=1,
|
||||
num_children=0,
|
||||
children_ages="",
|
||||
hotel_code="HOTEL123",
|
||||
created_at=datetime.now(UTC),
|
||||
)
|
||||
|
||||
reservation_pairs = [(reservation, customer)]
|
||||
response = create_res_retrieve_response(reservation_pairs, config=test_config)
|
||||
|
||||
config = SerializerConfig(pretty_print=True, encoding="UTF-8")
|
||||
serializer = XmlSerializer(config=config)
|
||||
xml_output = serializer.render(
|
||||
response, ns_map={None: "http://www.opentravel.org/OTA/2003/05"}
|
||||
)
|
||||
|
||||
assert response is not None
|
||||
assert xml_output is not None
|
||||
|
||||
def test_reservation_with_all_utm_parameters(self, test_config):
|
||||
"""Test reservation with all UTM tracking parameters."""
|
||||
customer = Customer(
|
||||
id=97,
|
||||
given_name="Marketing",
|
||||
surname="Test",
|
||||
contact_id="CONTACT-97",
|
||||
)
|
||||
reservation = ReservationData(
|
||||
unique_id="RES-UTM-TEST",
|
||||
start_date=date(2025, 2, 1),
|
||||
end_date=date(2025, 2, 7),
|
||||
num_adults=2,
|
||||
num_children=0,
|
||||
children_ages=[],
|
||||
hotel_code="HOTEL123",
|
||||
created_at=datetime.now(UTC),
|
||||
utm_source="facebook",
|
||||
utm_medium="social",
|
||||
utm_campaign="spring2025",
|
||||
utm_term="luxury resort",
|
||||
utm_content="carousel_ad",
|
||||
fbclid="IwAR1234567890",
|
||||
gclid="",
|
||||
)
|
||||
|
||||
reservation_db = Reservation(
|
||||
id=97,
|
||||
customer_id=97,
|
||||
**reservation.model_dump(exclude_none=True),
|
||||
)
|
||||
|
||||
reservation_pairs = [(reservation_db, customer)]
|
||||
response = create_res_retrieve_response(reservation_pairs, config=test_config)
|
||||
|
||||
config = SerializerConfig(pretty_print=True)
|
||||
serializer = XmlSerializer(config=config)
|
||||
serializer.render(
|
||||
response, ns_map={None: "http://www.opentravel.org/OTA/2003/05"}
|
||||
)
|
||||
|
||||
assert response is not None
|
||||
# UTM parameters should be in comments or other fields
|
||||
|
||||
|
||||
class TestAcknowledgments:
|
||||
"""Test acknowledgments.
|
||||
|
||||
1. Setup AlpineBitsServer so that it can respond to sample read requests.
|
||||
2. Send acknowledgment requests and verify responses.
|
||||
3. Verify that acknowledgments are recorded in the database.
|
||||
4. Verify that Read Requests no longer return already acknowledged reservations.
|
||||
5. Verify that that still happens when SelectionCriteria date filters are applied.
|
||||
|
||||
"""
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def populated_db_session(
|
||||
self,
|
||||
test_db_session,
|
||||
sample_reservation,
|
||||
sample_customer,
|
||||
minimal_reservation,
|
||||
minimal_customer,
|
||||
):
|
||||
"""Create a database session with sample data."""
|
||||
# Add customers
|
||||
test_db_session.add(sample_customer)
|
||||
test_db_session.add(minimal_customer)
|
||||
await test_db_session.commit()
|
||||
|
||||
# Add reservations
|
||||
test_db_session.add(sample_reservation)
|
||||
test_db_session.add(minimal_reservation)
|
||||
await test_db_session.commit()
|
||||
|
||||
return test_db_session
|
||||
|
||||
@pytest.fixture
|
||||
def alpinebits_server(self, test_config):
|
||||
"""Create AlpineBitsServer instance for testing."""
|
||||
return AlpineBitsServer(config=test_config)
|
||||
|
||||
@pytest.fixture
|
||||
def notif_report_xml_template(self):
|
||||
"""Template for OTA_NotifReportRQ XML request."""
|
||||
return """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_NotifReportRQ xmlns="http://www.opentravel.org/OTA/2003/05"
|
||||
EchoToken="ACK-12345"
|
||||
TimeStamp="2024-10-07T10:00:00"
|
||||
Version="7.000">
|
||||
<NotifDetails>
|
||||
<HotelNotifReport>
|
||||
<HotelReservations>
|
||||
{reservations}
|
||||
</HotelReservations>
|
||||
</HotelNotifReport>
|
||||
</NotifDetails>
|
||||
</OTA_NotifReportRQ>"""
|
||||
|
||||
def create_notif_report_xml(self, unique_ids):
|
||||
"""Create a notification report XML with given unique IDs."""
|
||||
template = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_NotifReportRQ xmlns="http://www.opentravel.org/OTA/2003/05"
|
||||
EchoToken="ACK-12345"
|
||||
TimeStamp="2024-10-07T10:00:00"
|
||||
Version="7.000">
|
||||
<NotifDetails>
|
||||
<HotelNotifReport>
|
||||
<HotelReservations>
|
||||
{reservations}
|
||||
</HotelReservations>
|
||||
</HotelNotifReport>
|
||||
</NotifDetails>
|
||||
</OTA_NotifReportRQ>"""
|
||||
|
||||
reservations = ""
|
||||
for unique_id in unique_ids:
|
||||
reservations += f'<HotelReservation><UniqueID Type="14" ID="{unique_id}"/></HotelReservation>'
|
||||
|
||||
return template.format(reservations=reservations)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_setup_server_responds_to_read_requests(
|
||||
self, alpinebits_server, populated_db_session, client_info, read_request_xml
|
||||
):
|
||||
"""Test 1: Setup AlpineBitsServer so that it can respond to sample read requests."""
|
||||
# Send a read request and verify we get a response
|
||||
response = await alpinebits_server.handle_request(
|
||||
request_action_name="OTA_Read:GuestRequests",
|
||||
request_xml=read_request_xml,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
dbsession=populated_db_session,
|
||||
)
|
||||
|
||||
assert response is not None
|
||||
assert response.status_code == HTTP_OK
|
||||
assert response.xml_content is not None
|
||||
|
||||
# Verify response contains reservation data
|
||||
assert "OTA_ResRetrieveRS" in response.xml_content
|
||||
assert "HOTEL123" in response.xml_content
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_send_acknowledgment_and_verify_response(
|
||||
self, alpinebits_server, populated_db_session, client_info
|
||||
):
|
||||
"""Test 2: Send acknowledgment requests and verify responses."""
|
||||
# First, get the unique IDs from a read request
|
||||
read_xml = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_ReadRQ xmlns="http://www.opentravel.org/OTA/2003/05"
|
||||
EchoToken="12345"
|
||||
TimeStamp="2024-10-07T10:00:00"
|
||||
Version="8.000">
|
||||
<ReadRequests>
|
||||
<HotelReadRequest HotelCode="HOTEL123" HotelName="Alpine Paradise Resort"/>
|
||||
</ReadRequests>
|
||||
</OTA_ReadRQ>"""
|
||||
|
||||
# Get reservations first
|
||||
_read_response = await alpinebits_server.handle_request(
|
||||
request_action_name="OTA_Read:GuestRequests",
|
||||
request_xml=read_xml,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
dbsession=populated_db_session,
|
||||
)
|
||||
|
||||
# Extract unique IDs from the response (we'll use test unique IDs)
|
||||
test_unique_ids = [
|
||||
"RES-2024-001",
|
||||
"RES-2024-002",
|
||||
] # In reality, these would be extracted from read response
|
||||
|
||||
# Create acknowledgment request
|
||||
notif_report_xml = self.create_notif_report_xml(test_unique_ids)
|
||||
|
||||
# Send acknowledgment
|
||||
ack_response = await alpinebits_server.handle_request(
|
||||
request_action_name="OTA_NotifReport:GuestRequests",
|
||||
request_xml=notif_report_xml,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
dbsession=populated_db_session,
|
||||
)
|
||||
|
||||
assert ack_response is not None
|
||||
assert ack_response.status_code == HTTP_OK
|
||||
assert "OTA_NotifReportRS" in ack_response.xml_content
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_acknowledgments_recorded_in_database(
|
||||
self, alpinebits_server, populated_db_session, client_info
|
||||
):
|
||||
"""Test 3: Verify that acknowledgments are recorded in the database."""
|
||||
# Create acknowledgment request
|
||||
test_unique_ids = ["test-ack-id-1", "test-ack-id-2"]
|
||||
notif_report_xml = self.create_notif_report_xml(test_unique_ids)
|
||||
|
||||
# Count existing acked requests
|
||||
result = await populated_db_session.execute(select(AckedRequest))
|
||||
initial_count = len(result.all())
|
||||
|
||||
# Send acknowledgment
|
||||
await alpinebits_server.handle_request(
|
||||
request_action_name="OTA_NotifReport:GuestRequests",
|
||||
request_xml=notif_report_xml,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
dbsession=populated_db_session,
|
||||
)
|
||||
|
||||
# Verify acknowledgments were recorded
|
||||
result = await populated_db_session.execute(select(AckedRequest))
|
||||
acked_requests = result.all()
|
||||
assert len(acked_requests) == initial_count + 2
|
||||
|
||||
# Verify the specific acknowledgments
|
||||
acked_ids = [req[0].unique_id for req in acked_requests]
|
||||
assert "test-ack-id-1" in acked_ids
|
||||
assert "test-ack-id-2" in acked_ids
|
||||
|
||||
# Verify client ID is recorded
|
||||
for req in acked_requests[-2:]: # Last 2 requests
|
||||
assert req[0].client_id == client_info.client_id
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_read_excludes_acknowledged_reservations(
|
||||
self, alpinebits_server, populated_db_session, client_info
|
||||
):
|
||||
"""Test 4: Verify that Read Requests no longer return already acknowledged reservations."""
|
||||
# First read request - should return all reservations
|
||||
read_xml = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_ReadRQ xmlns="http://www.opentravel.org/OTA/2003/05"
|
||||
EchoToken="12345"
|
||||
TimeStamp="2024-10-07T10:00:00"
|
||||
Version="8.000">
|
||||
<ReadRequests>
|
||||
<HotelReadRequest HotelCode="HOTEL123" HotelName="Alpine Paradise Resort"/>
|
||||
</ReadRequests>
|
||||
</OTA_ReadRQ>"""
|
||||
|
||||
initial_response = await alpinebits_server.handle_request(
|
||||
request_action_name="OTA_Read:GuestRequests",
|
||||
request_xml=read_xml,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
dbsession=populated_db_session,
|
||||
)
|
||||
|
||||
# Parse response to count initial reservations
|
||||
parser = XmlParser()
|
||||
initial_parsed = parser.from_string(
|
||||
initial_response.xml_content, OtaResRetrieveRs
|
||||
)
|
||||
initial_count = 0
|
||||
if (
|
||||
initial_parsed.reservations_list
|
||||
and initial_parsed.reservations_list.hotel_reservation
|
||||
):
|
||||
initial_count = len(initial_parsed.reservations_list.hotel_reservation)
|
||||
|
||||
# Acknowledge one reservation by using its MD5 hash
|
||||
# Get the unique_id from sample reservation and create its MD5
|
||||
sample_unique_id = "RES-2024-001"
|
||||
md5_hash = hashlib.md5(sample_unique_id.encode()).hexdigest()
|
||||
|
||||
# Manually insert acknowledgment
|
||||
acked_request = AckedRequest(
|
||||
unique_id=md5_hash,
|
||||
client_id=client_info.client_id,
|
||||
timestamp=datetime.now(UTC),
|
||||
)
|
||||
populated_db_session.add(acked_request)
|
||||
await populated_db_session.commit()
|
||||
|
||||
# Second read request - should return fewer reservations
|
||||
second_response = await alpinebits_server.handle_request(
|
||||
request_action_name="OTA_Read:GuestRequests",
|
||||
request_xml=read_xml,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
dbsession=populated_db_session,
|
||||
)
|
||||
|
||||
# Parse second response
|
||||
second_parsed = parser.from_string(
|
||||
second_response.xml_content, OtaResRetrieveRs
|
||||
)
|
||||
second_count = 0
|
||||
if (
|
||||
second_parsed.reservations_list
|
||||
and second_parsed.reservations_list.hotel_reservation
|
||||
):
|
||||
second_count = len(second_parsed.reservations_list.hotel_reservation)
|
||||
|
||||
# Should have one fewer reservation
|
||||
assert second_count == initial_count - 1
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_acknowledgments_work_with_date_filters(
|
||||
self,
|
||||
alpinebits_server,
|
||||
populated_db_session,
|
||||
client_info,
|
||||
read_request_xml_no_date_filter,
|
||||
):
|
||||
"""Test 5: Verify acknowledgments still work when SelectionCriteria date filters are applied."""
|
||||
# Read request with date filter
|
||||
read_xml_with_date = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_ReadRQ xmlns="http://www.opentravel.org/OTA/2003/05"
|
||||
EchoToken="12345"
|
||||
TimeStamp="2024-10-07T10:00:00"
|
||||
Version="8.000">
|
||||
<ReadRequests>
|
||||
<HotelReadRequest HotelCode="HOTEL123" HotelName="Alpine Paradise Resort">
|
||||
<SelectionCriteria Start="2024-12-01"/>
|
||||
</HotelReadRequest>
|
||||
</ReadRequests>
|
||||
</OTA_ReadRQ>"""
|
||||
|
||||
# First read with date filter
|
||||
initial_response = await alpinebits_server.handle_request(
|
||||
request_action_name="OTA_Read:GuestRequests",
|
||||
request_xml=read_xml_with_date,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
dbsession=populated_db_session,
|
||||
)
|
||||
|
||||
parser = XmlParser()
|
||||
initial_parsed = parser.from_string(
|
||||
initial_response.xml_content, OtaResRetrieveRs
|
||||
)
|
||||
initial_count = 0
|
||||
if (
|
||||
initial_parsed.reservations_list
|
||||
and initial_parsed.reservations_list.hotel_reservation
|
||||
):
|
||||
initial_count = len(initial_parsed.reservations_list.hotel_reservation)
|
||||
|
||||
assert initial_count > 0, "Initial count with date filter should be > 0"
|
||||
assert initial_count == 1, (
|
||||
"Should only return one reservation with this date filter"
|
||||
)
|
||||
|
||||
# Acknowledge one reservation that falls within the date range
|
||||
# The sample_reservation was created at 2024-11-01 and thus falls out of range
|
||||
sample_unique_id = "RES-2024-002"
|
||||
md5_hash = hashlib.md5(sample_unique_id.encode()).hexdigest()
|
||||
|
||||
acked_request = AckedRequest(
|
||||
unique_id=md5_hash,
|
||||
client_id=client_info.client_id,
|
||||
timestamp=datetime.now(UTC),
|
||||
)
|
||||
populated_db_session.add(acked_request)
|
||||
await populated_db_session.commit()
|
||||
|
||||
without_filter_read = await alpinebits_server.handle_request(
|
||||
request_action_name="OTA_Read:GuestRequests",
|
||||
request_xml=read_request_xml_no_date_filter,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
dbsession=populated_db_session,
|
||||
)
|
||||
|
||||
without_filter_parsed = parser.from_string(
|
||||
without_filter_read.xml_content, OtaResRetrieveRs
|
||||
)
|
||||
|
||||
without_filter_count = 0
|
||||
if (
|
||||
without_filter_parsed.reservations_list
|
||||
and without_filter_parsed.reservations_list.hotel_reservation
|
||||
):
|
||||
without_filter_count = len(
|
||||
without_filter_parsed.reservations_list.hotel_reservation
|
||||
)
|
||||
|
||||
assert without_filter_count == 1, (
|
||||
"Without date filter, should return one reservation after acknowledgment"
|
||||
)
|
||||
|
||||
# Second read with same date filter
|
||||
second_response = await alpinebits_server.handle_request(
|
||||
request_action_name="OTA_Read:GuestRequests",
|
||||
request_xml=read_xml_with_date,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
dbsession=populated_db_session,
|
||||
)
|
||||
|
||||
second_parsed = parser.from_string(
|
||||
second_response.xml_content, OtaResRetrieveRs
|
||||
)
|
||||
second_count = 0
|
||||
if (
|
||||
second_parsed.reservations_list
|
||||
and second_parsed.reservations_list.hotel_reservation
|
||||
):
|
||||
second_count = len(second_parsed.reservations_list.hotel_reservation)
|
||||
|
||||
# Should have exactly the same amount of reservations
|
||||
assert second_count == initial_count, (
|
||||
"Acknowledgment should not affect count when date filter is applied"
|
||||
)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_same_customer_multiple_reservations(
|
||||
self,
|
||||
alpinebits_server,
|
||||
test_db_session,
|
||||
client_info,
|
||||
sample_customer,
|
||||
):
|
||||
"""Test same customer with multiple reservations returns all."""
|
||||
# Add the customer to the database
|
||||
test_db_session.add(sample_customer)
|
||||
await test_db_session.commit()
|
||||
|
||||
# Create two reservations for the same customer
|
||||
first_reservation = ReservationData(
|
||||
unique_id="RES-2024-MULTI-001",
|
||||
start_date=date(2024, 12, 25),
|
||||
end_date=date(2024, 12, 31),
|
||||
num_adults=2,
|
||||
num_children=0,
|
||||
children_ages=[],
|
||||
hotel_code="HOTEL123",
|
||||
hotel_name="Alpine Paradise Resort",
|
||||
created_at=datetime(2024, 11, 1, 12, 0, 0, tzinfo=UTC),
|
||||
)
|
||||
|
||||
second_reservation = ReservationData(
|
||||
unique_id="RES-2024-MULTI-002",
|
||||
start_date=date(2025, 3, 15),
|
||||
end_date=date(2025, 3, 20),
|
||||
num_adults=2,
|
||||
num_children=1,
|
||||
children_ages=[10],
|
||||
hotel_code="HOTEL123",
|
||||
hotel_name="Alpine Paradise Resort",
|
||||
created_at=datetime(2024, 11, 15, 10, 0, 0, tzinfo=UTC),
|
||||
)
|
||||
|
||||
# Convert to DB reservations
|
||||
first_data = first_reservation.model_dump(exclude_none=True)
|
||||
children_list = first_data.pop("children_ages", [])
|
||||
children_csv = (
|
||||
",".join(str(int(a)) for a in children_list) if children_list else ""
|
||||
)
|
||||
first_data["children_ages"] = children_csv
|
||||
|
||||
db_first_reservation = Reservation(
|
||||
id=100,
|
||||
customer_id=sample_customer.id,
|
||||
**first_data,
|
||||
)
|
||||
|
||||
second_data = second_reservation.model_dump(exclude_none=True)
|
||||
children_list = second_data.pop("children_ages", [])
|
||||
children_csv = (
|
||||
",".join(str(int(a)) for a in children_list) if children_list else ""
|
||||
)
|
||||
second_data["children_ages"] = children_csv
|
||||
|
||||
db_second_reservation = Reservation(
|
||||
id=101,
|
||||
customer_id=sample_customer.id,
|
||||
**second_data,
|
||||
)
|
||||
|
||||
# Add both reservations to the database
|
||||
test_db_session.add(db_first_reservation)
|
||||
test_db_session.add(db_second_reservation)
|
||||
await test_db_session.commit()
|
||||
|
||||
# Send read request
|
||||
read_xml = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_ReadRQ xmlns="http://www.opentravel.org/OTA/2003/05"
|
||||
EchoToken="12345"
|
||||
TimeStamp="2024-10-07T10:00:00"
|
||||
Version="8.000">
|
||||
<ReadRequests>
|
||||
<HotelReadRequest HotelCode="HOTEL123" HotelName="Alpine Paradise Resort"/>
|
||||
</ReadRequests>
|
||||
</OTA_ReadRQ>"""
|
||||
|
||||
response = await alpinebits_server.handle_request(
|
||||
request_action_name="OTA_Read:GuestRequests",
|
||||
request_xml=read_xml,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
dbsession=test_db_session,
|
||||
)
|
||||
|
||||
assert response is not None
|
||||
assert response.status_code == HTTP_OK
|
||||
|
||||
# Parse response to verify both reservations are returned
|
||||
parser = XmlParser()
|
||||
parsed_response = parser.from_string(response.xml_content, OtaResRetrieveRs)
|
||||
|
||||
assert parsed_response.reservations_list is not None
|
||||
assert parsed_response.reservations_list.hotel_reservation is not None
|
||||
|
||||
reservation_count = len(parsed_response.reservations_list.hotel_reservation)
|
||||
expected_reservations = 2
|
||||
assert reservation_count == expected_reservations, (
|
||||
"Should return 2 reservations for the same customer"
|
||||
)
|
||||
|
||||
# Verify both reservations are present in the response
|
||||
xml_content = response.xml_content
|
||||
assert "John" in xml_content # Customer first name
|
||||
assert "Doe" in xml_content # Customer last name
|
||||
|
||||
# Both reservations should be linked to the same customer
|
||||
# Verify this by checking that customer appears in both reservation contexts
|
||||
min_customer_name_occurrences = 2
|
||||
assert xml_content.count("John") >= min_customer_name_occurrences, (
|
||||
"Customer name should appear for each reservation"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-v"])
|
||||
99
tests/test_alpinebits_server_ping.py
Normal file
99
tests/test_alpinebits_server_ping.py
Normal file
@@ -0,0 +1,99 @@
|
||||
import json
|
||||
|
||||
import pytest
|
||||
from xsdata_pydantic.bindings import XmlParser
|
||||
|
||||
from alpine_bits_python.alpinebits_server import AlpineBitsClientInfo, AlpineBitsServer
|
||||
from alpine_bits_python.generated.alpinebits import OtaPingRs
|
||||
|
||||
|
||||
def extract_relevant_sections(xml_string):
|
||||
# Remove version attribute value, keep only presence
|
||||
# Use the same XmlParser as AlpineBitsServer
|
||||
parser = XmlParser()
|
||||
return parser.from_string(xml_string, OtaPingRs)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ping_action_response_matches_expected():
|
||||
with open("tests/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
|
||||
server = AlpineBitsServer()
|
||||
with open("tests/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
|
||||
request_xml = f.read()
|
||||
with open("tests/test_data/Handshake-OTA_PingRS.xml", encoding="utf-8") as f:
|
||||
expected_xml = f.read()
|
||||
client_info = AlpineBitsClientInfo(username="irrelevant", password="irrelevant")
|
||||
response = await server.handle_request(
|
||||
request_action_name="OTA_Ping:Handshaking",
|
||||
request_xml=request_xml,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
)
|
||||
actual_obj = extract_relevant_sections(response.xml_content)
|
||||
expected_obj = extract_relevant_sections(expected_xml)
|
||||
|
||||
actual_matches = json.loads(actual_obj.warnings.warning[0].content[0])
|
||||
|
||||
expected_matches = json.loads(expected_obj.warnings.warning[0].content[0])
|
||||
|
||||
assert actual_matches == expected_matches, (
|
||||
f"Expected warnings {expected_matches}, got {actual_matches}"
|
||||
)
|
||||
|
||||
actual_capabilities = json.loads(actual_obj.echo_data)
|
||||
expected_capabilities = json.loads(expected_obj.echo_data)
|
||||
|
||||
assert actual_capabilities == expected_capabilities, (
|
||||
f"Expected echo data {expected_capabilities}, got {actual_capabilities}"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ping_action_response_success():
|
||||
server = AlpineBitsServer()
|
||||
with open("tests/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
|
||||
request_xml = f.read()
|
||||
client_info = AlpineBitsClientInfo(username="irrelevant", password="irrelevant")
|
||||
response = await server.handle_request(
|
||||
request_action_name="OTA_Ping:Handshaking",
|
||||
request_xml=request_xml,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert "<OTA_PingRS" in response.xml_content
|
||||
assert "<Success" in response.xml_content
|
||||
assert "Version=" in response.xml_content
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ping_action_response_version_arbitrary():
|
||||
server = AlpineBitsServer()
|
||||
with open("tests/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
|
||||
request_xml = f.read()
|
||||
client_info = AlpineBitsClientInfo(username="irrelevant", password="irrelevant")
|
||||
response = await server.handle_request(
|
||||
request_action_name="OTA_Ping:Handshaking",
|
||||
request_xml=request_xml,
|
||||
client_info=client_info,
|
||||
version="2022-10",
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert "<OTA_PingRS" in response.xml_content
|
||||
assert "Version=" in response.xml_content
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ping_action_response_invalid_action():
|
||||
server = AlpineBitsServer()
|
||||
with open("tests/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
|
||||
request_xml = f.read()
|
||||
client_info = AlpineBitsClientInfo(username="irrelevant", password="irrelevant")
|
||||
response = await server.handle_request(
|
||||
request_action_name="InvalidAction",
|
||||
request_xml=request_xml,
|
||||
client_info=client_info,
|
||||
version="2024-10",
|
||||
)
|
||||
assert response.status_code == 400
|
||||
assert "Error" in response.xml_content
|
||||
723
tests/test_api.py
Normal file
723
tests/test_api.py
Normal file
@@ -0,0 +1,723 @@
|
||||
"""Tests for API endpoints using FastAPI TestClient.
|
||||
|
||||
This module tests all FastAPI endpoints including:
|
||||
- Health check endpoints
|
||||
- Wix webhook endpoints
|
||||
- AlpineBits server endpoint
|
||||
- XML upload endpoint
|
||||
- Authentication
|
||||
- Rate limiting
|
||||
"""
|
||||
|
||||
import base64
|
||||
import gzip
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
||||
|
||||
from alpine_bits_python.api import app
|
||||
from alpine_bits_python.db import Base, Customer, Reservation
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def test_db_engine():
|
||||
"""Create an in-memory SQLite database for testing."""
|
||||
engine = create_async_engine(
|
||||
"sqlite+aiosqlite:///:memory:",
|
||||
echo=False,
|
||||
)
|
||||
|
||||
# Create tables
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
|
||||
yield engine
|
||||
|
||||
# Cleanup
|
||||
await engine.dispose()
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def test_db_session(test_db_engine):
|
||||
"""Create a test database session."""
|
||||
async_session = async_sessionmaker(
|
||||
test_db_engine,
|
||||
class_=AsyncSession,
|
||||
expire_on_commit=False,
|
||||
)
|
||||
|
||||
async with async_session() as session:
|
||||
yield session
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def test_config():
|
||||
"""Test configuration."""
|
||||
return {
|
||||
"server": {
|
||||
"codecontext": "ADVERTISING",
|
||||
"code": "70597314",
|
||||
"companyname": "99tales Gmbh",
|
||||
"res_id_source_context": "99tales",
|
||||
},
|
||||
"alpine_bits_auth": [
|
||||
{
|
||||
"hotel_id": "HOTEL123",
|
||||
"hotel_name": "Test Hotel",
|
||||
"username": "testuser",
|
||||
"password": "testpass",
|
||||
}
|
||||
],
|
||||
"default_hotel_code": "HOTEL123",
|
||||
"default_hotel_name": "Test Hotel",
|
||||
"database": {"url": "sqlite+aiosqlite:///:memory:"},
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client(test_config):
|
||||
"""Create a test client with mocked dependencies.
|
||||
|
||||
Each test gets a fresh TestClient instance to avoid database conflicts.
|
||||
Mocks load_config to return test_config instead of production config.
|
||||
"""
|
||||
# Import locally to avoid circular imports
|
||||
from alpine_bits_python.alpinebits_server import AlpineBitsServer # noqa: PLC0415
|
||||
|
||||
# Mock load_config to return test_config instead of production config
|
||||
with patch("alpine_bits_python.api.load_config", return_value=test_config):
|
||||
# Create a new in-memory database for each test
|
||||
engine = create_async_engine(
|
||||
"sqlite+aiosqlite:///:memory:",
|
||||
echo=False,
|
||||
)
|
||||
|
||||
# Setup app state (will be overridden by lifespan but we set it anyway)
|
||||
app.state.engine = engine
|
||||
app.state.async_sessionmaker = async_sessionmaker(
|
||||
engine, expire_on_commit=False
|
||||
)
|
||||
app.state.config = test_config
|
||||
app.state.alpine_bits_server = AlpineBitsServer(test_config)
|
||||
|
||||
# TestClient will trigger lifespan events which create the tables
|
||||
# The mocked load_config will ensure test_config is used
|
||||
with TestClient(app) as test_client:
|
||||
yield test_client
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_wix_form_data():
|
||||
"""Sample Wix form submission data.
|
||||
|
||||
Each call generates unique IDs to avoid database conflicts.
|
||||
"""
|
||||
unique_id = uuid.uuid4().hex[:8]
|
||||
return {
|
||||
"data": {
|
||||
"submissionId": f"test-submission-{unique_id}",
|
||||
"submissionTime": "2025-10-07T05:48:41.855Z",
|
||||
"contact": {
|
||||
"name": {"first": "John", "last": "Doe"},
|
||||
"email": f"john.doe.{unique_id}@example.com",
|
||||
"phones": [{"e164Phone": "+1234567890"}],
|
||||
"locale": "en-US",
|
||||
"contactId": f"contact-{unique_id}",
|
||||
},
|
||||
"field:anrede": "Mr.",
|
||||
"field:form_field_5a7b": "Checked",
|
||||
"field:date_picker_a7c8": "2024-12-25",
|
||||
"field:date_picker_7e65": "2024-12-31",
|
||||
"field:number_7cf5": "2",
|
||||
"field:anzahl_kinder": "1",
|
||||
"field:alter_kind_1": "8",
|
||||
"field:angebot_auswaehlen": "Christmas Special",
|
||||
"field:utm_source": "google",
|
||||
"field:utm_medium": "cpc",
|
||||
"field:utm_campaign": "winter2024",
|
||||
"field:fbclid": "test_fbclid_123",
|
||||
"field:long_answer_3524": "Late check-in please",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def basic_auth_headers():
|
||||
"""Create Basic Auth headers for testing."""
|
||||
credentials = base64.b64encode(b"testuser:testpass").decode("utf-8")
|
||||
return {"Authorization": f"Basic {credentials}"}
|
||||
|
||||
|
||||
class TestHealthEndpoints:
|
||||
"""Test health check and root endpoints."""
|
||||
|
||||
def test_root_endpoint(self, client):
|
||||
"""Test GET / returns health status."""
|
||||
response = client.get("/api/")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["message"] == "Wix Form Handler API is running"
|
||||
assert "timestamp" in data
|
||||
assert data["status"] == "healthy"
|
||||
assert "rate_limits" in data
|
||||
|
||||
def test_health_check_endpoint(self, client):
|
||||
"""Test GET /api/health returns healthy status."""
|
||||
response = client.get("/api/health")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "healthy"
|
||||
assert data["service"] == "wix-form-handler"
|
||||
assert data["version"] == "1.0.0"
|
||||
assert "timestamp" in data
|
||||
|
||||
def test_landing_page(self, client):
|
||||
"""Test GET / (landing page) returns HTML."""
|
||||
response = client.get("/")
|
||||
assert response.status_code == 200
|
||||
assert "text/html" in response.headers["content-type"]
|
||||
assert "99tales" in response.text or "Construction" in response.text
|
||||
|
||||
|
||||
class TestWixWebhookEndpoint:
|
||||
"""Test Wix form webhook endpoint."""
|
||||
|
||||
def test_wix_webhook_success(self, client, sample_wix_form_data):
|
||||
"""Test successful Wix form submission."""
|
||||
response = client.post("/api/webhook/wix-form", json=sample_wix_form_data)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "success"
|
||||
assert "timestamp" in data
|
||||
assert "data_logged_to" in data
|
||||
|
||||
def test_wix_webhook_creates_customer_and_reservation(
|
||||
self, client, sample_wix_form_data
|
||||
):
|
||||
"""Test that webhook creates customer and reservation in database."""
|
||||
response = client.post("/api/webhook/wix-form", json=sample_wix_form_data)
|
||||
assert response.status_code == 200
|
||||
|
||||
# Verify data was saved to database
|
||||
# Use the client's app state engine, not a separate test_db_engine
|
||||
async def check_db():
|
||||
engine = client.app.state.engine
|
||||
async_session = async_sessionmaker(engine, expire_on_commit=False)
|
||||
async with async_session() as session:
|
||||
from sqlalchemy import select
|
||||
|
||||
# Check customer was created
|
||||
result = await session.execute(select(Customer))
|
||||
customers = result.scalars().all()
|
||||
assert len(customers) == 1
|
||||
customer = customers[0]
|
||||
assert customer.given_name == "John"
|
||||
assert customer.surname == "Doe"
|
||||
# Email address in sample_wix_form_data has unique ID appended
|
||||
assert customer.email_address.startswith("john.doe.")
|
||||
assert "@example.com" in customer.email_address
|
||||
|
||||
# Check reservation was created
|
||||
result = await session.execute(select(Reservation))
|
||||
reservations = result.scalars().all()
|
||||
assert len(reservations) == 1
|
||||
reservation = reservations[0]
|
||||
assert reservation.customer_id == customer.id
|
||||
assert reservation.num_adults == 2
|
||||
assert reservation.num_children == 1
|
||||
|
||||
import asyncio
|
||||
|
||||
asyncio.run(check_db())
|
||||
|
||||
def test_wix_webhook_minimal_data(self, client):
|
||||
"""Test webhook with minimal required data."""
|
||||
minimal_data = {
|
||||
"data": {
|
||||
"submissionId": "minimal-123",
|
||||
"submissionTime": "2025-01-10T12:00:00.000Z",
|
||||
"contact": {
|
||||
"name": {"first": "Jane", "last": "Smith"},
|
||||
"email": "jane@example.com",
|
||||
},
|
||||
"field:date_picker_a7c8": "2025-01-15",
|
||||
"field:date_picker_7e65": "2025-01-20",
|
||||
}
|
||||
}
|
||||
|
||||
response = client.post("/api/webhook/wix-form", json=minimal_data)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "success"
|
||||
|
||||
def test_wix_webhook_test_endpoint(self, client, sample_wix_form_data):
|
||||
"""Test the test endpoint works identically."""
|
||||
response = client.post("/api/webhook/wix-form/test", json=sample_wix_form_data)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "success"
|
||||
|
||||
def test_wix_webhook_updates_existing_customer(self, client):
|
||||
"""Test that same contact_id updates customer instead of duplicate."""
|
||||
# First submission
|
||||
first_submission = {
|
||||
"data": {
|
||||
"submissionId": "test-submission-001",
|
||||
"submissionTime": "2025-10-07T05:48:41.855Z",
|
||||
"contact": {
|
||||
"name": {"first": "John", "last": "Doe"},
|
||||
"email": "john.doe@example.com",
|
||||
"phones": [{"e164Phone": "+1234567890"}],
|
||||
"locale": "en-US",
|
||||
"contactId": "fixed-contact-id-123",
|
||||
},
|
||||
"field:anrede": "Mr.",
|
||||
"field:date_picker_a7c8": "2024-12-25",
|
||||
"field:date_picker_7e65": "2024-12-31",
|
||||
"field:number_7cf5": "2",
|
||||
"field:anzahl_kinder": "0",
|
||||
}
|
||||
}
|
||||
|
||||
response = client.post("/api/webhook/wix-form", json=first_submission)
|
||||
assert response.status_code == 200
|
||||
|
||||
# Second submission with same contact_id but different data
|
||||
second_submission = {
|
||||
"data": {
|
||||
"submissionId": "test-submission-002",
|
||||
"submissionTime": "2025-10-08T10:30:00.000Z",
|
||||
"contact": {
|
||||
"name": {"first": "John", "last": "Smith"}, # Changed last name
|
||||
"email": "john.smith@example.com", # Changed email
|
||||
"phones": [{"e164Phone": "+9876543210"}], # Changed phone
|
||||
"locale": "de-DE", # Changed locale
|
||||
"contactId": "fixed-contact-id-123", # Same contact_id
|
||||
},
|
||||
"field:anrede": "Dr.", # Changed prefix
|
||||
"field:date_picker_a7c8": "2025-01-10",
|
||||
"field:date_picker_7e65": "2025-01-15",
|
||||
"field:number_7cf5": "4",
|
||||
"field:anzahl_kinder": "2",
|
||||
"field:alter_kind_1": "5",
|
||||
"field:alter_kind_2": "10",
|
||||
}
|
||||
}
|
||||
|
||||
response = client.post("/api/webhook/wix-form", json=second_submission)
|
||||
assert response.status_code == 200
|
||||
|
||||
# Verify only one customer exists with updated information
|
||||
async def check_db():
|
||||
from sqlalchemy import select # noqa: PLC0415
|
||||
|
||||
engine = client.app.state.engine
|
||||
async_session = async_sessionmaker(engine, expire_on_commit=False)
|
||||
async with async_session() as session:
|
||||
|
||||
# Check only one customer exists
|
||||
result = await session.execute(select(Customer))
|
||||
customers = result.scalars().all()
|
||||
assert len(customers) == 1, "Should have exactly one customer"
|
||||
|
||||
customer = customers[0]
|
||||
# Verify customer was updated with new information
|
||||
assert customer.given_name == "John"
|
||||
assert customer.surname == "Smith", "Last name updated"
|
||||
assert (
|
||||
customer.email_address == "john.smith@example.com"
|
||||
), "Email updated"
|
||||
assert customer.phone == "+9876543210", "Phone updated"
|
||||
assert customer.name_prefix == "Dr.", "Prefix updated"
|
||||
assert customer.language == "de", "Language updated"
|
||||
assert customer.contact_id == "fixed-contact-id-123"
|
||||
|
||||
# Check both reservations were created
|
||||
result = await session.execute(select(Reservation))
|
||||
reservations = result.scalars().all()
|
||||
expected_reservations = 2
|
||||
assert len(reservations) == expected_reservations
|
||||
# Both reservations should be linked to the same customer
|
||||
assert all(r.customer_id == customer.id for r in reservations)
|
||||
|
||||
import asyncio # noqa: PLC0415
|
||||
|
||||
asyncio.run(check_db())
|
||||
|
||||
|
||||
class TestGenericWebhookEndpoint:
|
||||
"""Test generic webhook endpoint."""
|
||||
|
||||
def test_generic_webhook_success(self, client):
|
||||
"""Test successful generic webhook submission."""
|
||||
test_data = {
|
||||
"event_type": "test_event",
|
||||
"data": {
|
||||
"key1": "value1",
|
||||
"key2": "value2",
|
||||
"nested": {"foo": "bar"},
|
||||
},
|
||||
"metadata": {"source": "test_system"},
|
||||
}
|
||||
|
||||
response = client.post("/api/webhook/generic", json=test_data)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "success"
|
||||
assert "timestamp" in data
|
||||
assert "data_logged_to" in data
|
||||
assert "generic_webhooks" in data["data_logged_to"]
|
||||
assert data["note"] == "Data logged for later analysis"
|
||||
|
||||
def test_generic_webhook_empty_payload(self, client):
|
||||
"""Test generic webhook with empty payload."""
|
||||
response = client.post("/api/webhook/generic", json={})
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "success"
|
||||
|
||||
def test_generic_webhook_complex_nested_data(self, client):
|
||||
"""Test generic webhook with complex nested data structures."""
|
||||
complex_data = {
|
||||
"arrays": [1, 2, 3],
|
||||
"nested": {"level1": {"level2": {"level3": "deep"}}},
|
||||
"mixed": [{"a": 1}, {"b": 2}],
|
||||
}
|
||||
|
||||
response = client.post("/api/webhook/generic", json=complex_data)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["status"] == "success"
|
||||
|
||||
|
||||
class TestAlpineBitsServerEndpoint:
|
||||
"""Test AlpineBits server endpoint."""
|
||||
|
||||
def test_alpinebits_handshake_ping_success(self, client, basic_auth_headers):
|
||||
"""Test AlpineBits handshake with OTA_Ping action using real test data."""
|
||||
# Use the actual test data file with proper AlpineBits handshake format
|
||||
with Path("tests/test_data/Handshake-OTA_PingRQ.xml").open(
|
||||
encoding="utf-8"
|
||||
) as f:
|
||||
ping_xml = f.read()
|
||||
|
||||
# Prepare multipart form data
|
||||
form_data = {"action": "OTA_Ping:Handshaking", "request": ping_xml}
|
||||
|
||||
headers = {
|
||||
**basic_auth_headers,
|
||||
"X-AlpineBits-ClientProtocolVersion": "2024-10",
|
||||
"X-AlpineBits-ClientID": "TEST-CLIENT-001",
|
||||
}
|
||||
|
||||
response = client.post(
|
||||
"/api/alpinebits/server-2024-10",
|
||||
data=form_data,
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "OTA_PingRS" in response.text
|
||||
assert "application/xml" in response.headers["content-type"]
|
||||
assert "X-AlpineBits-Server-Version" in response.headers
|
||||
|
||||
def test_alpinebits_missing_auth(self, client):
|
||||
"""Test AlpineBits endpoint without authentication."""
|
||||
form_data = {"action": "OTA_Ping:Handshaking", "request": "<xml/>"}
|
||||
|
||||
response = client.post("/api/alpinebits/server-2024-10", data=form_data)
|
||||
|
||||
assert response.status_code == 401
|
||||
|
||||
def test_alpinebits_invalid_credentials(self, client):
|
||||
"""Test AlpineBits endpoint with invalid credentials."""
|
||||
credentials = base64.b64encode(b"wrong:credentials").decode("utf-8")
|
||||
headers = {"Authorization": f"Basic {credentials}"}
|
||||
|
||||
form_data = {"action": "OTA_Ping:Handshaking", "request": "<xml/>"}
|
||||
|
||||
response = client.post(
|
||||
"/api/alpinebits/server-2024-10", data=form_data, headers=headers
|
||||
)
|
||||
|
||||
assert response.status_code == 401
|
||||
|
||||
def test_alpinebits_missing_action(self, client, basic_auth_headers):
|
||||
"""Test AlpineBits endpoint without action parameter."""
|
||||
headers = {
|
||||
**basic_auth_headers,
|
||||
"X-AlpineBits-ClientProtocolVersion": "2024-10",
|
||||
}
|
||||
|
||||
form_data = {"request": "<xml/>"}
|
||||
|
||||
response = client.post(
|
||||
"/api/alpinebits/server-2024-10", data=form_data, headers=headers
|
||||
)
|
||||
|
||||
assert response.status_code == 400
|
||||
|
||||
def test_alpinebits_gzip_compression(self, client, basic_auth_headers):
|
||||
"""Test AlpineBits endpoint with gzip compressed request."""
|
||||
# Use real test data
|
||||
with open("tests/test_data/Handshake-OTA_PingRQ.xml", encoding="utf-8") as f:
|
||||
ping_xml = f.read()
|
||||
|
||||
form_data = f"action=OTA_Ping:Handshaking&request={ping_xml}"
|
||||
compressed_data = gzip.compress(form_data.encode("utf-8"))
|
||||
|
||||
headers = {
|
||||
**basic_auth_headers,
|
||||
"X-AlpineBits-ClientProtocolVersion": "2024-10",
|
||||
"Content-Encoding": "gzip",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
}
|
||||
|
||||
response = client.post(
|
||||
"/api/alpinebits/server-2024-10",
|
||||
content=compressed_data,
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "OTA_PingRS" in response.text
|
||||
|
||||
|
||||
class TestXMLUploadEndpoint:
|
||||
"""Test XML upload endpoint for conversions."""
|
||||
|
||||
def test_xml_upload_success(self, client, basic_auth_headers):
|
||||
"""Test successful XML upload."""
|
||||
xml_content = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_HotelResNotifRQ xmlns="http://www.opentravel.org/OTA/2003/05">
|
||||
<HotelReservations>
|
||||
<HotelReservation>
|
||||
<UniqueID Type="14" ID="TEST-123"/>
|
||||
</HotelReservation>
|
||||
</HotelReservations>
|
||||
</OTA_HotelResNotifRQ>"""
|
||||
|
||||
response = client.put(
|
||||
"/api/hoteldata/conversions_import/test_reservation.xml",
|
||||
content=xml_content.encode("utf-8"),
|
||||
headers={**basic_auth_headers, "Content-Type": "application/xml"},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Xml received" in response.text
|
||||
|
||||
def test_xml_upload_gzip_compressed(self, client, basic_auth_headers):
|
||||
"""Test XML upload with gzip compression."""
|
||||
xml_content = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_HotelResNotifRQ xmlns="http://www.opentravel.org/OTA/2003/05">
|
||||
<HotelReservations/>
|
||||
</OTA_HotelResNotifRQ>"""
|
||||
|
||||
compressed = gzip.compress(xml_content.encode("utf-8"))
|
||||
|
||||
headers = {
|
||||
**basic_auth_headers,
|
||||
"Content-Type": "application/xml",
|
||||
"Content-Encoding": "gzip",
|
||||
}
|
||||
|
||||
response = client.put(
|
||||
"/api/hoteldata/conversions_import/compressed.xml",
|
||||
content=compressed,
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
def test_xml_upload_missing_auth(self, client):
|
||||
"""Test XML upload without authentication."""
|
||||
response = client.put(
|
||||
"/api/hoteldata/conversions_import/test.xml",
|
||||
content=b"<xml/>",
|
||||
)
|
||||
|
||||
assert response.status_code == 401
|
||||
|
||||
def test_xml_upload_invalid_path(self, client, basic_auth_headers):
|
||||
"""Test XML upload with path traversal attempt.
|
||||
|
||||
Path traversal is blocked by the server, resulting in 404 Not Found.
|
||||
"""
|
||||
response = client.put(
|
||||
"/api/hoteldata/conversions_import/../../../etc/passwd",
|
||||
content=b"<xml/>",
|
||||
headers=basic_auth_headers,
|
||||
)
|
||||
|
||||
# Path traversal results in 404 as the normalized path doesn't match the route
|
||||
assert response.status_code == 404
|
||||
|
||||
def test_xml_upload_empty_content(self, client, basic_auth_headers):
|
||||
"""Test XML upload with empty content."""
|
||||
response = client.put(
|
||||
"/api/hoteldata/conversions_import/empty.xml",
|
||||
content=b"",
|
||||
headers=basic_auth_headers,
|
||||
)
|
||||
|
||||
assert response.status_code == 400
|
||||
|
||||
def test_xml_upload_non_xml_content(self, client, basic_auth_headers):
|
||||
"""Test XML upload with non-XML content."""
|
||||
response = client.put(
|
||||
"/api/hoteldata/conversions_import/notxml.xml",
|
||||
content=b"This is not XML content",
|
||||
headers=basic_auth_headers,
|
||||
)
|
||||
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
class TestAuthentication:
|
||||
"""Test authentication and authorization."""
|
||||
|
||||
def test_basic_auth_success(self, client):
|
||||
"""Test successful basic authentication."""
|
||||
credentials = base64.b64encode(b"testuser:testpass").decode("utf-8")
|
||||
headers = {"Authorization": f"Basic {credentials}"}
|
||||
|
||||
form_data = {"action": "OTA_Ping:Handshaking", "request": "<xml/>"}
|
||||
|
||||
response = client.post(
|
||||
"/api/alpinebits/server-2024-10",
|
||||
data=form_data,
|
||||
headers={
|
||||
**headers,
|
||||
"X-AlpineBits-ClientProtocolVersion": "2024-10",
|
||||
},
|
||||
)
|
||||
|
||||
# Should not be 401
|
||||
assert response.status_code != 401
|
||||
|
||||
def test_basic_auth_missing_credentials(self, client):
|
||||
"""Test basic auth with missing credentials."""
|
||||
response = client.post(
|
||||
"/api/alpinebits/server-2024-10",
|
||||
data={"action": "OTA_Ping:Handshaking"},
|
||||
)
|
||||
|
||||
assert response.status_code == 401
|
||||
|
||||
def test_basic_auth_malformed_header(self, client):
|
||||
"""Test basic auth with malformed Authorization header."""
|
||||
headers = {"Authorization": "Basic malformed"}
|
||||
|
||||
response = client.post(
|
||||
"/api/alpinebits/server-2024-10",
|
||||
data={"action": "OTA_Ping:Handshaking"},
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
# FastAPI should handle this gracefully
|
||||
assert response.status_code in [401, 422]
|
||||
|
||||
|
||||
class TestEventDispatcher:
|
||||
"""Test event dispatcher and push notifications."""
|
||||
|
||||
def test_form_submission_triggers_event(
|
||||
self, client, sample_wix_form_data
|
||||
):
|
||||
"""Test that form submission triggers event dispatcher."""
|
||||
# Just verify the endpoint works with the event dispatcher
|
||||
# The async task runs in background and doesn't affect response
|
||||
response = client.post("/api/webhook/wix-form", json=sample_wix_form_data)
|
||||
|
||||
assert response.status_code == 200
|
||||
# Event dispatcher is tested separately in its own test suite
|
||||
|
||||
|
||||
class TestErrorHandling:
|
||||
"""Test error handling across endpoints."""
|
||||
|
||||
def test_wix_webhook_invalid_json(self, client):
|
||||
"""Test webhook with invalid JSON."""
|
||||
response = client.post(
|
||||
"/api/webhook/wix-form",
|
||||
content=b"invalid json {{{",
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
|
||||
assert response.status_code == 422
|
||||
|
||||
def test_wix_webhook_missing_required_fields(self, client):
|
||||
"""Test webhook with missing required fields."""
|
||||
invalid_data = {"data": {}}
|
||||
|
||||
response = client.post("/api/webhook/wix-form", json=invalid_data)
|
||||
|
||||
# Should handle gracefully - may be 500 or 400 depending on validation
|
||||
assert response.status_code in [400, 500]
|
||||
|
||||
def test_alpinebits_invalid_xml(self, client, basic_auth_headers):
|
||||
"""Test AlpineBits endpoint with invalid XML."""
|
||||
form_data = {
|
||||
"action": "OTA_Ping:Handshaking",
|
||||
"request": "<<invalid xml>>",
|
||||
}
|
||||
|
||||
headers = {
|
||||
**basic_auth_headers,
|
||||
"X-AlpineBits-ClientProtocolVersion": "2024-10",
|
||||
}
|
||||
|
||||
response = client.post(
|
||||
"/api/alpinebits/server-2024-10",
|
||||
data=form_data,
|
||||
headers=headers,
|
||||
)
|
||||
|
||||
# Should return error response
|
||||
assert response.status_code in [400, 500]
|
||||
|
||||
|
||||
class TestCORS:
|
||||
"""Test CORS configuration."""
|
||||
|
||||
def test_cors_preflight_request(self, client):
|
||||
"""Test CORS preflight request."""
|
||||
response = client.options(
|
||||
"/api/health",
|
||||
headers={
|
||||
"Origin": "https://example.wix.com",
|
||||
"Access-Control-Request-Method": "POST",
|
||||
},
|
||||
)
|
||||
|
||||
# TestClient returns 400 for OPTIONS requests
|
||||
# In production, CORS middleware handles preflight correctly
|
||||
assert response.status_code in [200, 400, 405]
|
||||
|
||||
|
||||
class TestRateLimiting:
|
||||
"""Test rate limiting (requires actual rate limiter to be active)."""
|
||||
|
||||
def test_health_endpoint_rate_limit(self, client):
|
||||
"""Test that health endpoint has rate limiting configured."""
|
||||
# Make multiple requests
|
||||
responses = []
|
||||
for _ in range(5):
|
||||
response = client.get("/api/health")
|
||||
responses.append(response.status_code)
|
||||
|
||||
# All should succeed if under limit
|
||||
assert all(status == 200 for status in responses)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-v"])
|
||||
158
tests/test_data/Handshake-OTA_PingRQ.xml
Normal file
158
tests/test_data/Handshake-OTA_PingRQ.xml
Normal file
@@ -0,0 +1,158 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
AlpineBits 2024-10
|
||||
https://www.alpinebits.org/
|
||||
|
||||
Sample message file for a Handshake request
|
||||
|
||||
Changelog:
|
||||
v. 2024-10 1.2 Example extended with all capabilities and two supported releases
|
||||
v. 2024-10 1.1 Removed the OTA_Ping action
|
||||
v. 2024-10 1.0 added supported version 2024-10 in the example
|
||||
v. 2018-10 1.0 initial example
|
||||
-->
|
||||
|
||||
<OTA_PingRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.opentravel.org/OTA/2003/05"
|
||||
xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_PingRQ.xsd"
|
||||
Version="8.000">
|
||||
<EchoData>
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"version": "2024-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests_StatusUpdate"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelInvCountNotif",
|
||||
"supports": [
|
||||
"OTA_HotelInvCountNotif_accept_rooms",
|
||||
"OTA_HotelInvCountNotif_accept_categories",
|
||||
"OTA_HotelInvCountNotif_accept_deltas",
|
||||
"OTA_HotelInvCountNotif_accept_out_of_market",
|
||||
"OTA_HotelInvCountNotif_accept_out_of_order",
|
||||
"OTA_HotelInvCountNotif_accept_complete_set",
|
||||
"OTA_HotelInvCountNotif_accept_closing_seasons"
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveContentNotif_Inventory",
|
||||
"supports": [
|
||||
"OTA_HotelDescriptiveContentNotif_Inventory_use_rooms",
|
||||
"OTA_HotelDescriptiveContentNotif_Inventory_occupancy_children"
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveContentNotif_Info"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveInfo_Inventory"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveInfo_Info"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelRatePlanNotif_RatePlans",
|
||||
"supports": [
|
||||
"OTA_HotelRatePlanNotif_accept_ArrivalDOW",
|
||||
"OTA_HotelRatePlanNotif_accept_DepartureDOW",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlan_BookingRule",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlan_RoomType_BookingRule",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlan_mixed_BookingRule",
|
||||
"OTA_HotelRatePlanNotif_accept_Supplements",
|
||||
"OTA_HotelRatePlanNotif_accept_FreeNightsOffers",
|
||||
"OTA_HotelRatePlanNotif_accept_FamilyOffers",
|
||||
"OTA_HotelRatePlanNotif_accept_full",
|
||||
"OTA_HotelRatePlanNotif_accept_overlay",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlanJoin",
|
||||
"OTA_HotelRatePlanNotif_accept_OfferRule_BookingOffset",
|
||||
"OTA_HotelRatePlanNotif_accept_OfferRule_DOWLOS"
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelRatePlan_BaseRates",
|
||||
"supports": [
|
||||
"OTA_HotelRatePlan_BaseRates_deltas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelPostEventNotif_EventReports"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2022-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Ping"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests_StatusUpdate"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelInvCountNotif",
|
||||
"supports": [
|
||||
"OTA_HotelInvCountNotif_accept_rooms",
|
||||
"OTA_HotelInvCountNotif_accept_categories",
|
||||
"OTA_HotelInvCountNotif_accept_deltas",
|
||||
"OTA_HotelInvCountNotif_accept_out_of_market",
|
||||
"OTA_HotelInvCountNotif_accept_out_of_order",
|
||||
"OTA_HotelInvCountNotif_accept_complete_set",
|
||||
"OTA_HotelInvCountNotif_accept_closing_seasons"
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveContentNotif_Inventory",
|
||||
"supports": [
|
||||
"OTA_HotelDescriptiveContentNotif_Inventory_use_rooms",
|
||||
"OTA_HotelDescriptiveContentNotif_Inventory_occupancy_children"
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveContentNotif_Info"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveInfo_Inventory"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveInfo_Info"
|
||||
},
|
||||
|
||||
{
|
||||
"action": "action_OTA_HotelRatePlanNotif_RatePlans",
|
||||
"supports": [
|
||||
"OTA_HotelRatePlanNotif_accept_ArrivalDOW",
|
||||
"OTA_HotelRatePlanNotif_accept_DepartureDOW",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlan_BookingRule",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlan_RoomType_BookingRule",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlan_mixed_BookingRule",
|
||||
"OTA_HotelRatePlanNotif_accept_Supplements",
|
||||
"OTA_HotelRatePlanNotif_accept_FreeNightsOffers",
|
||||
"OTA_HotelRatePlanNotif_accept_FamilyOffers",
|
||||
"OTA_HotelRatePlanNotif_accept_overlay",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlanJoin",
|
||||
"OTA_HotelRatePlanNotif_accept_OfferRule_BookingOffset",
|
||||
"OTA_HotelRatePlanNotif_accept_OfferRule_DOWLOS"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
</EchoData>
|
||||
</OTA_PingRQ>
|
||||
190
tests/test_data/Handshake-OTA_PingRS.xml
Normal file
190
tests/test_data/Handshake-OTA_PingRS.xml
Normal file
@@ -0,0 +1,190 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
AlpineBits 2024-10
|
||||
https://www.alpinebits.org/
|
||||
|
||||
Sample message file for a Handshake response
|
||||
|
||||
Changelog:
|
||||
v. 2024-10 1.2 Example extended with all capabilities and two supported releases
|
||||
v. 2024-10 1.1 Removed the OTA_Ping action
|
||||
v. 2024-10 1.0 added supported version 2024-10 in the example
|
||||
v. 2018-10 1.0 initial example
|
||||
-->
|
||||
|
||||
<OTA_PingRS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.opentravel.org/OTA/2003/05"
|
||||
xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_PingRS.xsd"
|
||||
Version="8.000">
|
||||
<Success/>
|
||||
<Warnings>
|
||||
<Warning Type="11" Status="ALPINEBITS_HANDSHAKE">{
|
||||
"versions": [
|
||||
{
|
||||
"version": "2024-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2022-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Ping"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}</Warning>
|
||||
</Warnings>
|
||||
<EchoData>
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"version": "2024-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests_StatusUpdate"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelInvCountNotif",
|
||||
"supports": [
|
||||
"OTA_HotelInvCountNotif_accept_rooms",
|
||||
"OTA_HotelInvCountNotif_accept_categories",
|
||||
"OTA_HotelInvCountNotif_accept_deltas",
|
||||
"OTA_HotelInvCountNotif_accept_out_of_market",
|
||||
"OTA_HotelInvCountNotif_accept_out_of_order",
|
||||
"OTA_HotelInvCountNotif_accept_complete_set",
|
||||
"OTA_HotelInvCountNotif_accept_closing_seasons"
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveContentNotif_Inventory",
|
||||
"supports": [
|
||||
"OTA_HotelDescriptiveContentNotif_Inventory_use_rooms",
|
||||
"OTA_HotelDescriptiveContentNotif_Inventory_occupancy_children"
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveContentNotif_Info"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveInfo_Inventory"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveInfo_Info"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelRatePlanNotif_RatePlans",
|
||||
"supports": [
|
||||
"OTA_HotelRatePlanNotif_accept_ArrivalDOW",
|
||||
"OTA_HotelRatePlanNotif_accept_DepartureDOW",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlan_BookingRule",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlan_RoomType_BookingRule",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlan_mixed_BookingRule",
|
||||
"OTA_HotelRatePlanNotif_accept_Supplements",
|
||||
"OTA_HotelRatePlanNotif_accept_FreeNightsOffers",
|
||||
"OTA_HotelRatePlanNotif_accept_FamilyOffers",
|
||||
"OTA_HotelRatePlanNotif_accept_full",
|
||||
"OTA_HotelRatePlanNotif_accept_overlay",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlanJoin",
|
||||
"OTA_HotelRatePlanNotif_accept_OfferRule_BookingOffset",
|
||||
"OTA_HotelRatePlanNotif_accept_OfferRule_DOWLOS"
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelRatePlan_BaseRates",
|
||||
"supports": [
|
||||
"OTA_HotelRatePlan_BaseRates_deltas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelPostEventNotif_EventReports"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2022-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Ping"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests_StatusUpdate"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelInvCountNotif",
|
||||
"supports": [
|
||||
"OTA_HotelInvCountNotif_accept_rooms",
|
||||
"OTA_HotelInvCountNotif_accept_categories",
|
||||
"OTA_HotelInvCountNotif_accept_deltas",
|
||||
"OTA_HotelInvCountNotif_accept_out_of_market",
|
||||
"OTA_HotelInvCountNotif_accept_out_of_order",
|
||||
"OTA_HotelInvCountNotif_accept_complete_set",
|
||||
"OTA_HotelInvCountNotif_accept_closing_seasons"
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveContentNotif_Inventory",
|
||||
"supports": [
|
||||
"OTA_HotelDescriptiveContentNotif_Inventory_use_rooms",
|
||||
"OTA_HotelDescriptiveContentNotif_Inventory_occupancy_children"
|
||||
]
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveContentNotif_Info"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveInfo_Inventory"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelDescriptiveInfo_Info"
|
||||
},
|
||||
|
||||
{
|
||||
"action": "action_OTA_HotelRatePlanNotif_RatePlans",
|
||||
"supports": [
|
||||
"OTA_HotelRatePlanNotif_accept_ArrivalDOW",
|
||||
"OTA_HotelRatePlanNotif_accept_DepartureDOW",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlan_BookingRule",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlan_RoomType_BookingRule",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlan_mixed_BookingRule",
|
||||
"OTA_HotelRatePlanNotif_accept_Supplements",
|
||||
"OTA_HotelRatePlanNotif_accept_FreeNightsOffers",
|
||||
"OTA_HotelRatePlanNotif_accept_FamilyOffers",
|
||||
"OTA_HotelRatePlanNotif_accept_overlay",
|
||||
"OTA_HotelRatePlanNotif_accept_RatePlanJoin",
|
||||
"OTA_HotelRatePlanNotif_accept_OfferRule_BookingOffset",
|
||||
"OTA_HotelRatePlanNotif_accept_OfferRule_DOWLOS"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
</EchoData>
|
||||
</OTA_PingRS>
|
||||
241
tests/test_data/test_form1.json
Normal file
241
tests/test_data/test_form1.json
Normal file
@@ -0,0 +1,241 @@
|
||||
{"data": {
|
||||
"formName": "Contact us",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Angebot auswählen",
|
||||
"value": "Zimmer: Doppelzimmer"
|
||||
},
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2025-10-21"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2025-12-28"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "4"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Herr"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Jonas"
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Linter"
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "jonas@vaius.ai"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+39 392 007 6982"
|
||||
},
|
||||
{
|
||||
"label": "Message",
|
||||
"value": "Hallo nachricht in der Kommentarsection"
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Angekreuzt"
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": "5"
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": "23065043477"
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": "EAIaIQobChMI-d7Bn_-OkAMVuZJQBh09uD0vEAAYASAAEgKR8_D_BwE"
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "hotelid",
|
||||
"value": "12345"
|
||||
},
|
||||
{
|
||||
"label": "hotelname",
|
||||
"value": "Bemelmans Post"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2025-10-28",
|
||||
"field:number_7cf5": "2",
|
||||
"field:utm_source": "",
|
||||
"submissionTime": "2025-10-06T07:05:34.001Z",
|
||||
"field:gad_source": "5",
|
||||
"field:form_field_5a7b": "Angekreuzt",
|
||||
"field:gad_campaignid": "23065043477",
|
||||
"field:utm_medium": "",
|
||||
"field:utm_term_id": "",
|
||||
"context": {
|
||||
"metaSiteId": "1dea821c-8168-4736-96e4-4b92e8b364cf",
|
||||
"activationId": "fd8e9c90-0335-4fd2-976d-985f065f3f80"
|
||||
},
|
||||
"field:email_5139": "jonas@vaius.ai",
|
||||
"field:phone_4c77": "+39 392 007 6982",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "fd8e9c90-0335-4fd2-976d-985f065f3f80"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "a976f18c-fa86-495d-be1e-676df188eeae"
|
||||
},
|
||||
"app": {
|
||||
"id": "225dd912-7dea-4738-8688-4b8c6955ffc2"
|
||||
},
|
||||
"action": {
|
||||
"id": "152db4d7-5263-40c4-be2b-1c81476318b7"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "nduaitreuditaor",
|
||||
"formFieldMask": [
|
||||
"field:",
|
||||
"field:",
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"field:hotelid",
|
||||
"field:hotelname",
|
||||
"field:",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Jonas",
|
||||
"last": "Linter"
|
||||
},
|
||||
"email": "jonas@vaius.ai",
|
||||
"locale": "de-de",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+393920076982",
|
||||
"id": "a3bf4-6dbe-4611-8963-a50df805785d",
|
||||
"countryCode": "DE",
|
||||
"e164Phone": "+393920076982",
|
||||
"primary": true,
|
||||
"phone": "392 0076982"
|
||||
}
|
||||
],
|
||||
"contactId": "66659da8-4035-47fe-a66b-6ce461ad290f",
|
||||
"emails": [
|
||||
{
|
||||
"id": "e1d2168e-ca3c-4844-8f93-f2e1b0ae70e3",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "koepper-ed@t-online.de",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-10-06T07:05:35.675Z",
|
||||
"phone": "+491758555456",
|
||||
"createdDate": "2025-10-06T07:05:35.675Z"
|
||||
},
|
||||
"submissionId": "666247dc-9d5a-4eb7-87a7-677bf64645ad",
|
||||
"field:anzahl_kinder": "0",
|
||||
"field:first_name_abae": "Ernst-Dieter",
|
||||
"field:utm_content_id": "",
|
||||
"field:utm_campaign": "",
|
||||
"field:utm_term": "",
|
||||
"contactId": "66659da8-4035-47fe-a66b-6ce461ad290f",
|
||||
"field:date_picker_a7c8": "2025-12-21",
|
||||
"field:hotelname": "Testhotel",
|
||||
"field:angebot_auswaehlen": "Zimmer: Doppelzimmer",
|
||||
"field:utm_content": "",
|
||||
"field:last_name_d97c": "Linter",
|
||||
"field:hotelid": "135",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/1dea821c-8168-4736-96e4-4b92e8b364cf/e084006b-ae83-4e4d-b2f5-074118cdb3b1?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F1dea821c-8168-4736-96e4-4b92e8b364cf%2Fwix-forms%2Fform%2Fe084006b-ae83-4e4d-b2f5-074118cdb3b1%2Fsubmissions&s=true",
|
||||
"field:gbraid": "",
|
||||
"field:fbclid": "",
|
||||
"submissionPdf": {
|
||||
"fileName": "86d247dc-9d5a-4eb7-87a7-677bf64645ad.pdf",
|
||||
"downloadUrl": "https://manage.wix.com/_api/form-submission-service/v4/submissions/86d247dc-9d5a-4eb7-87a7-677bf64645ad/download?accessToken=JWS.eyJraWQiOiJWLVNuLWhwZSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wibWV0YVNpdGVJZFwiOlwiMWRlYTgyMWMtODE2OC00NzM2LTk2ZTQtNGI5MmU4YjM2NGNmXCJ9IiwiaWF0IjoxNzU5NzM0MzM1LCJleHAiOjE3NTk3MzQ5MzV9.9koy-O_ptm0dRspjh01Yefkt2rCHiUlRCFtE_S3auYw"
|
||||
},
|
||||
"field:anrede": "Herr",
|
||||
"field:long_answer_3524": "Kommentarsektion vermutlich",
|
||||
"formId": "e084006b-ae83-4e4d-b2f5-074118cdb3b1"
|
||||
}}
|
||||
242
tests/test_data/test_form2.json
Normal file
242
tests/test_data/test_form2.json
Normal file
@@ -0,0 +1,242 @@
|
||||
{"data": {
|
||||
"formName": "Reservation Request",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Angebot auswählen",
|
||||
"value": "Zimmer: Einzelzimmer"
|
||||
},
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2025-11-15"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2025-11-18"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Frau"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Maria"
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Schmidt"
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "maria.schmidt@gmail.com"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+49 173 555 1234"
|
||||
},
|
||||
{
|
||||
"label": "Message",
|
||||
"value": "Benötige ein ruhiges Zimmer, bitte."
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Selezionato"
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": "google"
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": "cpc"
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": "winter_2025"
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": "hotel_booking"
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": "ad_variant_a"
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": "12345"
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": "67890"
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": "98765432"
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": "1.2.abc123def456"
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": "CjwKCAjw9eWYBhB3EiwAA5J8_xyz123abc"
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": "IwAR123fbclid456"
|
||||
},
|
||||
{
|
||||
"label": "hotelid",
|
||||
"value": "135"
|
||||
},
|
||||
{
|
||||
"label": "hotelname",
|
||||
"value": "Frangart Inn"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2025-11-18",
|
||||
"field:number_7cf5": "1",
|
||||
"field:utm_source": "google",
|
||||
"submissionTime": "2025-10-06T14:22:15.001Z",
|
||||
"field:gad_source": "1",
|
||||
"field:form_field_5a7b": "Selezionato",
|
||||
"field:gad_campaignid": "98765432",
|
||||
"field:utm_medium": "cpc",
|
||||
"field:utm_term_id": "12345",
|
||||
"context": {
|
||||
"metaSiteId": "2ebc832d-9279-5847-a7f5-5c03f9c475d0",
|
||||
"activationId": "0e9a0d91-1446-5fe3-a87e-a96b17f720c1"
|
||||
},
|
||||
"field:email_5139": "maria.schmidt@gmail.com",
|
||||
"field:phone_4c77": "+49 173 555 1234",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "0e9a0d91-1446-5fe3-a87e-a96b17f720c1"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "b087029d-0b97-506e-cf2f-787e0299ffbf"
|
||||
},
|
||||
"app": {
|
||||
"id": "336ee023-8efa-5849-9799-5c9d7066aac3"
|
||||
},
|
||||
"action": {
|
||||
"id": "263ec5e8-6374-51d5-df3c-2d92587429c8"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "CjwKCAjw9eWYBhB3EiwAA5J8_xyz123abc",
|
||||
"formFieldMask": [
|
||||
"field:",
|
||||
"field:",
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"field:hotelid",
|
||||
"field:hotelname",
|
||||
"field:",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Maria",
|
||||
"last": "Schmidt"
|
||||
},
|
||||
"email": "maria.schmidt@gmail.com",
|
||||
"locale": "de-de",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+49 173 555 1234",
|
||||
"id": "641b4cf5-7ecf-5722-9a74-b61ea916391e",
|
||||
"countryCode": "DE",
|
||||
"e164Phone": "+393920076982",
|
||||
"primary": true,
|
||||
"phone": "173 5551234"
|
||||
}
|
||||
],
|
||||
"contactId": "24760eb9-5146-58f0-b77c-7df572be401f",
|
||||
"emails": [
|
||||
{
|
||||
"id": "f2e3279f-db4d-5955-90a4-03f2c1bf81f4",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "maria.schmidt@gmail.com",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-10-06T14:22:16.675Z",
|
||||
"phone": "+393920076982",
|
||||
"createdDate": "2025-10-06T14:22:16.675Z"
|
||||
},
|
||||
"submissionId": "97e358ed-ae6b-5fc8-98c8-788cf75756be",
|
||||
"field:anzahl_kinder": "1",
|
||||
"field:first_name_abae": "Maria",
|
||||
"field:utm_content_id": "67890",
|
||||
"field:utm_campaign": "winter_2025",
|
||||
"field:utm_term": "hotel_booking",
|
||||
"contactId": "24760eb9-5146-58f0-b77c-7df572be401f",
|
||||
"field:date_picker_a7c8": "2025-11-15",
|
||||
"field:hotelname": "Frangart Inn",
|
||||
"field:angebot_auswaehlen": "Zimmer: Einzelzimmer",
|
||||
"field:utm_content": "ad_variant_a",
|
||||
"field:last_name_d97c": "Schmidt",
|
||||
"field:hotelid": "135",
|
||||
"field:alter_kind_3": "8",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/2ebc832d-9279-5847-a7f5-5c03f9c475d0/f195117c-bf94-5f5e-c6g6-185229dde4c2?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F2ebc832d-9279-5847-a7f5-5c03f9c475d0%2Fwix-forms%2Fform%2Ff195117c-bf94-5f5e-c6g6-185229dde4c2%2Fsubmissions&s=true",
|
||||
"field:gbraid": "1.2.abc123def456",
|
||||
"field:fbclid": "IwAR123fbclid456",
|
||||
"submissionPdf": {
|
||||
"fileName": "97e358ed-ae6b-5fc8-98c8-788cf75756be.pdf",
|
||||
"downloadUrl": "https://manage.wix.com/_api/form-submission-service/v4/submissions/97e358ed-ae6b-5fc8-98c8-788cf75756be/download?accessToken=JWS.eyJraWQiOiJWLVNuLWhwZSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wibWV0YVNpdGVJZFwiOlwiMmViYzgzMmQtOTI3OS01ODQ3LWE3ZjUtNWMwM2Y5YzQ3NWQwXCJ9IiwiaWF0IjoxNzU5ODQ1MzM2LCJleHAiOjE3NTk4NDU5MzZ9.abc123_different_token_here"
|
||||
},
|
||||
"field:anrede": "Frau",
|
||||
"field:long_answer_3524": "Benötige ein ruhiges Zimmer, bitte.",
|
||||
"formId": "f195117c-bf94-5f5e-c6g6-185229dde4c2"
|
||||
}}
|
||||
244
tests/test_data/test_form3.json
Normal file
244
tests/test_data/test_form3.json
Normal file
@@ -0,0 +1,244 @@
|
||||
{"data": {
|
||||
"formName": "Family Vacation Inquiry",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Angebot auswählen",
|
||||
"value": "Suite: Familiensuite"
|
||||
},
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2025-12-20"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2025-12-27"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "3"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Herr"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Alessandro"
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Rossi"
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "alessandro.rossi@example.it"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+39 348 123 4567"
|
||||
},
|
||||
{
|
||||
"label": "Message",
|
||||
"value": "Wir planen unseren Weihnachtsurlaub mit drei Kindern. Brauchen Kinderbetten und Nähe zum Spielplatz."
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": "Angekreuzt"
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": "facebook"
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": "social"
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": "christmas_special"
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": "family_hotel"
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": "carousel_ad"
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": "54321"
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": "09876"
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": "IwAR3xHcVb6eJbMqQ_fbsocial789"
|
||||
},
|
||||
{
|
||||
"label": "hotelid",
|
||||
"value": "135"
|
||||
},
|
||||
{
|
||||
"label": "hotelname",
|
||||
"value": "Bemelmans"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2025-12-27",
|
||||
"field:number_7cf5": "2",
|
||||
"field:utm_source": "facebook",
|
||||
"submissionTime": "2025-10-06T16:45:22.001Z",
|
||||
"field:gad_source": "",
|
||||
"field:form_field_5a7b": "Angekreuzt",
|
||||
"field:gad_campaignid": "",
|
||||
"field:utm_medium": "social",
|
||||
"field:utm_term_id": "54321",
|
||||
"context": {
|
||||
"metaSiteId": "3fcd943e-a38a-6958-b8g6-6d14gad586e1",
|
||||
"activationId": "1f0b1e02-2557-6gf4-b98f-ba7c28g831d2"
|
||||
},
|
||||
"field:email_5139": "alessandro.rossi@example.it",
|
||||
"field:phone_4c77": "+39 348 123 4567",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "1f0b1e02-2557-6gf4-b98f-ba7c28g831d2"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "c198130e-1ca8-617f-dg3g-898f1300ggcg"
|
||||
},
|
||||
"app": {
|
||||
"id": "447ff134-9g0b-6950-a8aa-6d0e8177bbdc"
|
||||
},
|
||||
"action": {
|
||||
"id": "374fd6f9-7485-62e6-eg4d-3e03698540d9"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "",
|
||||
"formFieldMask": [
|
||||
"field:",
|
||||
"field:",
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"field:hotelid",
|
||||
"field:hotelname",
|
||||
"field:",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Alessandro",
|
||||
"last": "Rossi"
|
||||
},
|
||||
"email": "alessandro.rossi@example.it",
|
||||
"locale": "it-it",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+39 348 123 4567",
|
||||
"id": "752c5dg6-8fdf-6833-ab85-c72fb027402f",
|
||||
"countryCode": "IT",
|
||||
"e164Phone": "+393481234567",
|
||||
"primary": true,
|
||||
"phone": "348 1234567"
|
||||
}
|
||||
],
|
||||
"contactId": "35871fca-6257-69g1-c88d-8eg683cf512g",
|
||||
"emails": [
|
||||
{
|
||||
"id": "g3f4380g-ec5e-6a66-a1b5-14g3d2cg92g5",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "alessandro.rossi@example.it",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-10-06T16:45:23.675Z",
|
||||
"phone": "+393481234567",
|
||||
"createdDate": "2025-10-06T16:45:23.675Z"
|
||||
},
|
||||
"submissionId": "a8g469fe-bf7c-6gd9-a9d9-899dg86867cf",
|
||||
"field:anzahl_kinder": "3",
|
||||
"field:first_name_abae": "Alessandro",
|
||||
"field:utm_content_id": "09876",
|
||||
"field:utm_campaign": "christmas_special",
|
||||
"field:utm_term": "family_hotel",
|
||||
"contactId": "35871fca-6257-69g1-c88d-8eg683cf512g",
|
||||
"field:date_picker_a7c8": "2025-12-20",
|
||||
"field:hotelname": "Bemelmans",
|
||||
"field:angebot_auswaehlen": "Suite: Familiensuite",
|
||||
"field:utm_content": "carousel_ad",
|
||||
"field:last_name_d97c": "Rossi",
|
||||
"field:hotelid": "135",
|
||||
"field:alter_kind_3": "12",
|
||||
"field:alter_kind_4": "9",
|
||||
"field:alter_kind_5": "6",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/3fcd943e-a38a-6958-b8g6-6d14gad586e1/g206228d-ch05-6g6f-d7h7-296330eef5d3?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F3fcd943e-a38a-6958-b8g6-6d14gad586e1%2Fwix-forms%2Fform%2Fg206228d-ch05-6g6f-d7h7-296330eef5d3%2Fsubmissions&s=true",
|
||||
"field:gbraid": "",
|
||||
"field:fbclid": "IwAR3xHcVb6eJbMqQ_fbsocial789",
|
||||
"submissionPdf": {
|
||||
"fileName": "a8g469fe-bf7c-6gd9-a9d9-899dg86867cf.pdf",
|
||||
"downloadUrl": "https://manage.wix.com/_api/form-submission-service/v4/submissions/a8g469fe-bf7c-6gd9-a9d9-899dg86867cf/download?accessToken=JWS.eyJraWQiOiJWLVNuLWhwZSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wibWV0YVNpdGVJZFwiOlwiM2ZjZDk0M2UtYTM4YS02OTU4LWI4ZzYtNmQxNGdhZDU4NmUxXCJ9IiwiaWF0IjoxNzU5ODUyMDQ3LCJleHAiOjE3NTk4NTI2NDd9.xyz789_another_token_here"
|
||||
},
|
||||
"field:anrede": "Herr",
|
||||
"field:long_answer_3524": "Wir planen unseren Weihnachtsurlaub mit drei Kindern. Brauchen Kinderbetten und Nähe zum Spielplatz.",
|
||||
"formId": "g206228d-ch05-6g6f-d7h7-296330eef5d3"
|
||||
}}
|
||||
241
tests/test_data/test_form4.json
Normal file
241
tests/test_data/test_form4.json
Normal file
@@ -0,0 +1,241 @@
|
||||
{"data": {
|
||||
"formName": "Business Travel Request",
|
||||
"submissions": [
|
||||
{
|
||||
"label": "Angebot auswählen",
|
||||
"value": "Zimmer: Business Suite"
|
||||
},
|
||||
{
|
||||
"label": "Anreisedatum",
|
||||
"value": "2025-11-08"
|
||||
},
|
||||
{
|
||||
"label": "Abreisedatum",
|
||||
"value": "2025-11-10"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Erwachsene",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"label": "Anzahl Kinder",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"label": "Anrede",
|
||||
"value": "Frau"
|
||||
},
|
||||
{
|
||||
"label": "Vorname",
|
||||
"value": "Sarah"
|
||||
},
|
||||
{
|
||||
"label": "Nachname",
|
||||
"value": "Johnson"
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"value": "sarah.johnson@businesscorp.com"
|
||||
},
|
||||
{
|
||||
"label": "Phone",
|
||||
"value": "+1 555 987 6543"
|
||||
},
|
||||
{
|
||||
"label": "Message",
|
||||
"value": "Business trip for conference. Need WiFi and workspace. Will arrive late on Monday."
|
||||
},
|
||||
{
|
||||
"label": "Einwilligung Marketing",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Source",
|
||||
"value": "direct"
|
||||
},
|
||||
{
|
||||
"label": "utm_Medium",
|
||||
"value": "none"
|
||||
},
|
||||
{
|
||||
"label": "utm_Campaign",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Term",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_Content",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_term_id",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "utm_content_id",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_source",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gad_campaignid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gbraid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "gclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "fbclid",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"label": "hotelid",
|
||||
"value": "135"
|
||||
},
|
||||
{
|
||||
"label": "hotelname",
|
||||
"value": "Business Hotel Alpine"
|
||||
}
|
||||
],
|
||||
"field:date_picker_7e65": "2025-11-10",
|
||||
"field:number_7cf5": "1",
|
||||
"field:utm_source": "direct",
|
||||
"submissionTime": "2025-10-06T09:15:45.001Z",
|
||||
"field:gad_source": "",
|
||||
"field:form_field_5a7b": "",
|
||||
"field:gad_campaignid": "",
|
||||
"field:utm_medium": "none",
|
||||
"field:utm_term_id": "",
|
||||
"context": {
|
||||
"metaSiteId": "4hde054f-b49b-7a69-c9h7-7e25hbe697f2",
|
||||
"activationId": "2g1c2f13-3668-7hg5-ca9g-cb8d39h942e3"
|
||||
},
|
||||
"field:email_5139": "sarah.johnson@businesscorp.com",
|
||||
"field:phone_4c77": "+1 555 987 6543",
|
||||
"_context": {
|
||||
"activation": {
|
||||
"id": "2g1c2f13-3668-7hg5-ca9g-cb8d39h942e3"
|
||||
},
|
||||
"configuration": {
|
||||
"id": "d2a9241f-2db9-728g-eh4h-9a9g2411hhd0"
|
||||
},
|
||||
"app": {
|
||||
"id": "558gg245-ah1c-7a61-b9bb-7e1f9288ccede"
|
||||
},
|
||||
"action": {
|
||||
"id": "485ge7ga-8596-73f7-fh5e-4f146a9651ea"
|
||||
},
|
||||
"trigger": {
|
||||
"key": "wix_form_app-form_submitted"
|
||||
}
|
||||
},
|
||||
"field:gclid": "",
|
||||
"formFieldMask": [
|
||||
"field:",
|
||||
"field:",
|
||||
"field:angebot_auswaehlen",
|
||||
"field:date_picker_a7c8",
|
||||
"field:date_picker_7e65",
|
||||
"field:",
|
||||
"field:number_7cf5",
|
||||
"field:anzahl_kinder",
|
||||
"field:alter_kind_3",
|
||||
"field:alter_kind_25",
|
||||
"field:alter_kind_4",
|
||||
"field:alter_kind_5",
|
||||
"field:alter_kind_6",
|
||||
"field:alter_kind_7",
|
||||
"field:alter_kind_8",
|
||||
"field:alter_kind_9",
|
||||
"field:alter_kind_10",
|
||||
"field:alter_kind_11",
|
||||
"field:",
|
||||
"field:anrede",
|
||||
"field:first_name_abae",
|
||||
"field:last_name_d97c",
|
||||
"field:email_5139",
|
||||
"field:phone_4c77",
|
||||
"field:long_answer_3524",
|
||||
"field:form_field_5a7b",
|
||||
"field:",
|
||||
"field:utm_source",
|
||||
"field:utm_medium",
|
||||
"field:utm_campaign",
|
||||
"field:utm_term",
|
||||
"field:utm_content",
|
||||
"field:utm_term_id",
|
||||
"field:utm_content_id",
|
||||
"field:gad_source",
|
||||
"field:gad_campaignid",
|
||||
"field:gbraid",
|
||||
"field:gclid",
|
||||
"field:fbclid",
|
||||
"field:hotelid",
|
||||
"field:hotelname",
|
||||
"field:",
|
||||
"metaSiteId"
|
||||
],
|
||||
"contact": {
|
||||
"name": {
|
||||
"first": "Sarah",
|
||||
"last": "Johnson"
|
||||
},
|
||||
"email": "sarah.johnson@businesscorp.com",
|
||||
"locale": "en-us",
|
||||
"phones": [
|
||||
{
|
||||
"tag": "UNTAGGED",
|
||||
"formattedPhone": "+1 555 987 6543",
|
||||
"id": "863d6eh7-9geg-7944-bc96-d83gc138513g",
|
||||
"countryCode": "US",
|
||||
"e164Phone": "+15559876543",
|
||||
"primary": true,
|
||||
"phone": "555 9876543"
|
||||
}
|
||||
],
|
||||
"contactId": "46982gdb-7368-7ah2-d99e-9fh794dg623h",
|
||||
"emails": [
|
||||
{
|
||||
"id": "h4g5491h-fd6f-7b77-b2c6-25h4e3dh03h6",
|
||||
"tag": "UNTAGGED",
|
||||
"email": "sarah.johnson@businesscorp.com",
|
||||
"primary": true
|
||||
}
|
||||
],
|
||||
"updatedDate": "2025-10-06T09:15:46.675Z",
|
||||
"phone": "+15559876543",
|
||||
"createdDate": "2025-10-06T09:15:46.675Z"
|
||||
},
|
||||
"submissionId": "b9h57agf-ch8d-7hea-baeb-9aaeth97978dg",
|
||||
"field:anzahl_kinder": "0",
|
||||
"field:first_name_abae": "Sarah",
|
||||
"field:utm_content_id": "",
|
||||
"field:utm_campaign": "",
|
||||
"field:utm_term": "",
|
||||
"contactId": "46982gdb-7368-7ah2-d99e-9fh794dg623h",
|
||||
"field:date_picker_a7c8": "2025-11-08",
|
||||
"field:hotelname": "Business Hotel Alpine",
|
||||
"field:angebot_auswaehlen": "Zimmer: Business Suite",
|
||||
"field:utm_content": "",
|
||||
"field:last_name_d97c": "Johnson",
|
||||
"field:hotelid": "135",
|
||||
"submissionsLink": "https://manage.wix.app/forms/submissions/4hde054f-b49b-7a69-c9h7-7e25hbe697f2/h317339e-di16-7h7g-e8i8-3a7441ffg6e4?d=https%3A%2F%2Fmanage.wix.com%2Fdashboard%2F4hde054f-b49b-7a69-c9h7-7e25hbe697f2%2Fwix-forms%2Fform%2Fh317339e-di16-7h7g-e8i8-3a7441ffg6e4%2Fsubmissions&s=true",
|
||||
"field:gbraid": "",
|
||||
"field:fbclid": "",
|
||||
"submissionPdf": {
|
||||
"fileName": "b9h57agf-ch8d-7hea-baeb-9aaeth97978dg.pdf",
|
||||
"downloadUrl": "https://manage.wix.com/_api/form-submission-service/v4/submissions/b9h57agf-ch8d-7hea-baeb-9aaeth97978dg/download?accessToken=JWS.eyJraWQiOiJWLVNuLWhwZSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wibWV0YVNpdGVJZFwiOlwiNGhkZTA1NGYtYjQ5Yi03YTY5LWM5aDctN2UyNWhiZTY5N2YyXCJ9IiwiaWF0IjoxNzU5ODI5MzQ2LCJleHAiOjE3NTk4Mjk5NDZ9.business_token_987654"
|
||||
},
|
||||
"field:anrede": "Frau",
|
||||
"field:long_answer_3524": "Business trip for conference. Need WiFi and workspace. Will arrive late on Monday.",
|
||||
"formId": "h317339e-di16-7h7g-e8i8-3a7441ffg6e4"
|
||||
}}
|
||||
64
tests/test_output/actual_ping_response.xml
Normal file
64
tests/test_output/actual_ping_response.xml
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OTA_PingRS xmlns="http://www.opentravel.org/OTA/2003/05" Version="7.000">
|
||||
<Success/>
|
||||
<Warnings>
|
||||
<Warning Type="11" Status="ALPINEBITS_HANDSHAKE">{
|
||||
"versions": [
|
||||
{
|
||||
"version": "2024-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2022-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Ping"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}</Warning>
|
||||
</Warnings>
|
||||
<EchoData>{
|
||||
"versions": [
|
||||
{
|
||||
"version": "2024-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2022-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_Ping"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}</EchoData>
|
||||
</OTA_PingRS>
|
||||
81
tests/test_output/expected_ping_response.xml
Normal file
81
tests/test_output/expected_ping_response.xml
Normal file
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
AlpineBits 2024-10
|
||||
https://www.alpinebits.org/
|
||||
|
||||
Sample message file for a Handshake response
|
||||
|
||||
Changelog:
|
||||
v. 2024-10 1.2 Example extended with all capabilities and two supported releases
|
||||
v. 2024-10 1.1 Removed the OTA_Ping action
|
||||
v. 2024-10 1.0 added supported version 2024-10 in the example
|
||||
v. 2018-10 1.0 initial example
|
||||
-->
|
||||
|
||||
<OTA_PingRS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://www.opentravel.org/OTA/2003/05"
|
||||
xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_PingRS.xsd"
|
||||
Version="8.000">
|
||||
<Success/>
|
||||
<Warnings>
|
||||
<Warning Type="11" Status="ALPINEBITS_HANDSHAKE">{
|
||||
"versions": [
|
||||
{
|
||||
"version": "2024-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2022-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Ping"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}</Warning>
|
||||
</Warnings>
|
||||
<EchoData>{
|
||||
"versions": [
|
||||
{
|
||||
"version": "2024-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "2022-10",
|
||||
"actions": [
|
||||
{
|
||||
"action": "action_OTA_Read"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_Ping"
|
||||
},
|
||||
{
|
||||
"action": "action_OTA_HotelResNotif_GuestRequests"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}</EchoData>
|
||||
</OTA_PingRS>
|
||||
Reference in New Issue
Block a user