pydropcountr 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pydropcountr-0.1.2/.github/workflows/ci.yml +67 -0
- pydropcountr-0.1.2/.github/workflows/publish.yml +101 -0
- pydropcountr-0.1.2/.gitignore +159 -0
- pydropcountr-0.1.2/CHANGELOG.md +118 -0
- pydropcountr-0.1.2/CLAUDE.md +138 -0
- pydropcountr-0.1.2/LICENSE +21 -0
- pydropcountr-0.1.2/PKG-INFO +359 -0
- pydropcountr-0.1.2/PUBLISHING.md +137 -0
- pydropcountr-0.1.2/README.md +325 -0
- pydropcountr-0.1.2/hello.py +6 -0
- pydropcountr-0.1.2/pydropcountr/__init__.py +24 -0
- pydropcountr-0.1.2/pydropcountr/cli.py +291 -0
- pydropcountr-0.1.2/pydropcountr/pydropcountr.py +533 -0
- pydropcountr-0.1.2/pyproject.toml +76 -0
- pydropcountr-0.1.2/test_login.py +165 -0
- pydropcountr-0.1.2/uv.lock +692 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main, develop ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint-and-test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.12", "3.13"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v4
|
|
21
|
+
with:
|
|
22
|
+
version: "latest"
|
|
23
|
+
|
|
24
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
25
|
+
run: uv python install ${{ matrix.python-version }}
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: |
|
|
29
|
+
uv sync --dev
|
|
30
|
+
|
|
31
|
+
- name: Run ruff linting
|
|
32
|
+
run: uv run ruff check --output-format=github .
|
|
33
|
+
|
|
34
|
+
- name: Run ruff formatting check
|
|
35
|
+
run: uv run ruff format --check .
|
|
36
|
+
|
|
37
|
+
- name: Run mypy type checking
|
|
38
|
+
run: uv run mypy pydropcountr/ --ignore-missing-imports
|
|
39
|
+
|
|
40
|
+
- name: Run tests
|
|
41
|
+
run: uv run python test_login.py
|
|
42
|
+
|
|
43
|
+
security:
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
|
|
48
|
+
- name: Install uv
|
|
49
|
+
uses: astral-sh/setup-uv@v4
|
|
50
|
+
|
|
51
|
+
- name: Set up Python
|
|
52
|
+
run: uv python install 3.12
|
|
53
|
+
|
|
54
|
+
- name: Install dependencies
|
|
55
|
+
run: uv sync --dev
|
|
56
|
+
|
|
57
|
+
- name: Run bandit security linter
|
|
58
|
+
run: |
|
|
59
|
+
uv add --dev bandit
|
|
60
|
+
uv run bandit -r pydropcountr/ -f json -o bandit-report.json || true
|
|
61
|
+
|
|
62
|
+
- name: Upload bandit results
|
|
63
|
+
uses: actions/upload-artifact@v4
|
|
64
|
+
if: always()
|
|
65
|
+
with:
|
|
66
|
+
name: bandit-results
|
|
67
|
+
path: bandit-report.json
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*' # Trigger on version tags like v1.0.0, v0.1.0, etc.
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ['3.12', '3.13']
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
21
|
+
uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install uv
|
|
26
|
+
uses: astral-sh/setup-uv@v4
|
|
27
|
+
with:
|
|
28
|
+
version: "latest"
|
|
29
|
+
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: |
|
|
32
|
+
uv sync --dev
|
|
33
|
+
|
|
34
|
+
- name: Run linting
|
|
35
|
+
run: |
|
|
36
|
+
uv run ruff check
|
|
37
|
+
|
|
38
|
+
- name: Run type checking
|
|
39
|
+
run: |
|
|
40
|
+
uv run mypy pydropcountr/ --ignore-missing-imports
|
|
41
|
+
|
|
42
|
+
- name: Run tests
|
|
43
|
+
run: |
|
|
44
|
+
uv run python test_login.py
|
|
45
|
+
|
|
46
|
+
build:
|
|
47
|
+
needs: test
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
|
|
50
|
+
steps:
|
|
51
|
+
- uses: actions/checkout@v4
|
|
52
|
+
|
|
53
|
+
- name: Set up Python
|
|
54
|
+
uses: actions/setup-python@v5
|
|
55
|
+
with:
|
|
56
|
+
python-version: '3.12'
|
|
57
|
+
|
|
58
|
+
- name: Install uv
|
|
59
|
+
uses: astral-sh/setup-uv@v4
|
|
60
|
+
with:
|
|
61
|
+
version: "latest"
|
|
62
|
+
|
|
63
|
+
- name: Install build dependencies
|
|
64
|
+
run: |
|
|
65
|
+
uv add --dev build
|
|
66
|
+
|
|
67
|
+
- name: Build package
|
|
68
|
+
run: |
|
|
69
|
+
uv run python -m build
|
|
70
|
+
|
|
71
|
+
- name: Check distribution
|
|
72
|
+
run: |
|
|
73
|
+
uv add --dev twine
|
|
74
|
+
uv run twine check dist/*
|
|
75
|
+
|
|
76
|
+
- name: Upload build artifacts
|
|
77
|
+
uses: actions/upload-artifact@v4
|
|
78
|
+
with:
|
|
79
|
+
name: dist
|
|
80
|
+
path: dist/
|
|
81
|
+
|
|
82
|
+
publish:
|
|
83
|
+
needs: [test, build]
|
|
84
|
+
runs-on: ubuntu-latest
|
|
85
|
+
environment: release
|
|
86
|
+
permissions:
|
|
87
|
+
id-token: write # Required for trusted publishing
|
|
88
|
+
|
|
89
|
+
steps:
|
|
90
|
+
- name: Download build artifacts
|
|
91
|
+
uses: actions/download-artifact@v4
|
|
92
|
+
with:
|
|
93
|
+
name: dist
|
|
94
|
+
path: dist/
|
|
95
|
+
|
|
96
|
+
- name: Publish to PyPI
|
|
97
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
98
|
+
with:
|
|
99
|
+
# Use trusted publishing - no need for API tokens
|
|
100
|
+
# Configure this in PyPI project settings
|
|
101
|
+
verify-metadata: true
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Environment files
|
|
2
|
+
.envrc
|
|
3
|
+
.env
|
|
4
|
+
.env.local
|
|
5
|
+
|
|
6
|
+
# Python cache
|
|
7
|
+
__pycache__/
|
|
8
|
+
*.py[cod]
|
|
9
|
+
*$py.class
|
|
10
|
+
*.so
|
|
11
|
+
|
|
12
|
+
# Distribution / packaging
|
|
13
|
+
.Python
|
|
14
|
+
build/
|
|
15
|
+
develop-eggs/
|
|
16
|
+
dist/
|
|
17
|
+
downloads/
|
|
18
|
+
eggs/
|
|
19
|
+
.eggs/
|
|
20
|
+
lib/
|
|
21
|
+
lib64/
|
|
22
|
+
parts/
|
|
23
|
+
sdist/
|
|
24
|
+
var/
|
|
25
|
+
wheels/
|
|
26
|
+
share/python-wheels/
|
|
27
|
+
*.egg-info/
|
|
28
|
+
.installed.cfg
|
|
29
|
+
*.egg
|
|
30
|
+
MANIFEST
|
|
31
|
+
|
|
32
|
+
# PyInstaller
|
|
33
|
+
*.manifest
|
|
34
|
+
*.spec
|
|
35
|
+
|
|
36
|
+
# Installer logs
|
|
37
|
+
pip-log.txt
|
|
38
|
+
pip-delete-this-directory.txt
|
|
39
|
+
|
|
40
|
+
# Unit test / coverage reports
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.nox/
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
.cache
|
|
47
|
+
nosetests.xml
|
|
48
|
+
coverage.xml
|
|
49
|
+
*.cover
|
|
50
|
+
*.py,cover
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
cover/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
.python-version
|
|
88
|
+
|
|
89
|
+
# pipenv
|
|
90
|
+
Pipfile.lock
|
|
91
|
+
|
|
92
|
+
# poetry
|
|
93
|
+
poetry.lock
|
|
94
|
+
|
|
95
|
+
# pdm
|
|
96
|
+
.pdm.toml
|
|
97
|
+
|
|
98
|
+
# PEP 582
|
|
99
|
+
__pypackages__/
|
|
100
|
+
|
|
101
|
+
# Celery stuff
|
|
102
|
+
celerybeat-schedule
|
|
103
|
+
celerybeat.pid
|
|
104
|
+
|
|
105
|
+
# SageMath parsed files
|
|
106
|
+
*.sage.py
|
|
107
|
+
|
|
108
|
+
# Environments
|
|
109
|
+
.venv
|
|
110
|
+
env/
|
|
111
|
+
venv/
|
|
112
|
+
ENV/
|
|
113
|
+
env.bak/
|
|
114
|
+
venv.bak/
|
|
115
|
+
|
|
116
|
+
# Spyder project settings
|
|
117
|
+
.spyderproject
|
|
118
|
+
.spyproject
|
|
119
|
+
|
|
120
|
+
# Rope project settings
|
|
121
|
+
.ropeproject
|
|
122
|
+
|
|
123
|
+
# mkdocs documentation
|
|
124
|
+
/site
|
|
125
|
+
|
|
126
|
+
# mypy
|
|
127
|
+
.mypy_cache/
|
|
128
|
+
.dmypy.json
|
|
129
|
+
dmypy.json
|
|
130
|
+
|
|
131
|
+
# Pyre type checker
|
|
132
|
+
.pyre/
|
|
133
|
+
|
|
134
|
+
# pytype static type analyzer
|
|
135
|
+
.pytype/
|
|
136
|
+
|
|
137
|
+
# Cython debug symbols
|
|
138
|
+
cython_debug/
|
|
139
|
+
|
|
140
|
+
# PyCharm
|
|
141
|
+
.idea/
|
|
142
|
+
|
|
143
|
+
# VS Code
|
|
144
|
+
.vscode/
|
|
145
|
+
|
|
146
|
+
# macOS
|
|
147
|
+
.DS_Store
|
|
148
|
+
|
|
149
|
+
# Windows
|
|
150
|
+
Thumbs.db
|
|
151
|
+
ehthumbs.db
|
|
152
|
+
Desktop.ini
|
|
153
|
+
|
|
154
|
+
# Temporary files
|
|
155
|
+
*.tmp
|
|
156
|
+
*.temp
|
|
157
|
+
*.swp
|
|
158
|
+
*.swo
|
|
159
|
+
*~
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to PyDropCountr will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.2] - 2025-01-03
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- All MyPy type checking errors for improved code quality and IDE support
|
|
14
|
+
- Missing return type annotations throughout library and CLI
|
|
15
|
+
- Type compatibility issues in ServiceConnection instantiation
|
|
16
|
+
- Return type consistency across all public methods
|
|
17
|
+
|
|
18
|
+
## [0.1.1] - 2025-01-03
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- GitHub Actions workflow for automated PyPI publishing with trusted publishing
|
|
22
|
+
- Debug logging support with `--debug` flag for CLI troubleshooting
|
|
23
|
+
- Comprehensive logging throughout library and CLI for better error tracking
|
|
24
|
+
- PUBLISHING.md guide for PyPI deployment and trusted publishing setup
|
|
25
|
+
- Support for multiple premises - now discovers all service connections across user's properties
|
|
26
|
+
- Complete address information (street, city, state, zip) in services and usage commands
|
|
27
|
+
- Service type information (Multi Family, Single Family) in services list
|
|
28
|
+
- Enhanced CLI with address display for better property identification
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
- API response format handling for `/api/me` endpoint (supports both old and new formats)
|
|
32
|
+
- Multiple premises support - fixed bug where only first premise's service connections were found
|
|
33
|
+
- Service connections discovery now works correctly across all user premises
|
|
34
|
+
- Email None handling in debug logging to prevent crashes with missing credentials
|
|
35
|
+
- Linting issues and code formatting for clean CI/CD runs
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
- Restructured project as proper Python package with `pydropcountr/` directory
|
|
39
|
+
- Updated build system to use Hatchling with comprehensive PyPI metadata
|
|
40
|
+
- Improved error messages and debugging capabilities throughout
|
|
41
|
+
- Enhanced address display format with complete location information
|
|
42
|
+
- Updated CI workflow to work with new package structure and latest tooling
|
|
43
|
+
|
|
44
|
+
## [0.3.0] - 2025-06-12
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
- Comprehensive CLI interface using Fire library
|
|
48
|
+
- Default behavior showing yesterday + last 7 days usage
|
|
49
|
+
- Support for all CLI flags (email, password, service_id, dates, period)
|
|
50
|
+
- Environment variable support for credentials (DROPCOUNTR_EMAIL, DROPCOUNTR_PASSWORD)
|
|
51
|
+
- CLI entry point in pyproject.toml as `dropcountr` command
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
- CLI now automatically selects first available service connection as default
|
|
55
|
+
|
|
56
|
+
## [0.2.0] - 2025-06-12
|
|
57
|
+
|
|
58
|
+
### Added
|
|
59
|
+
- Pydantic data models for type safety and validation
|
|
60
|
+
- Comprehensive README.md with usage examples
|
|
61
|
+
- GitHub Actions CI/CD pipeline with linting and testing
|
|
62
|
+
- Support for modern Python type hints (X | Y union syntax)
|
|
63
|
+
- Service connection management APIs (`list_service_connections`, `get_service_connection`)
|
|
64
|
+
- Support for Python datetime objects in `get_usage()` method (alongside ISO strings)
|
|
65
|
+
- Data validation constraints (e.g., gallons >= 0)
|
|
66
|
+
|
|
67
|
+
### Changed
|
|
68
|
+
- Migrated from dataclasses to Pydantic BaseModel for all data structures
|
|
69
|
+
- Updated to modern Python syntax throughout codebase
|
|
70
|
+
- Enhanced type hints and validation
|
|
71
|
+
|
|
72
|
+
### Fixed
|
|
73
|
+
- Date parameter handling now supports both datetime objects and ISO strings
|
|
74
|
+
- Improved error handling and validation
|
|
75
|
+
|
|
76
|
+
## [0.1.0] - 2025-05-25
|
|
77
|
+
|
|
78
|
+
### Added
|
|
79
|
+
- Initial PyDropCountr library implementation
|
|
80
|
+
- User authentication with login/logout functionality
|
|
81
|
+
- Session management with rack.session cookies
|
|
82
|
+
- Water usage data fetching with date ranges
|
|
83
|
+
- Structured data objects (ServiceConnection, UsageData, UsageResponse)
|
|
84
|
+
- Date parsing and validation utilities
|
|
85
|
+
- Support for uv dependency management
|
|
86
|
+
- Basic test suite
|
|
87
|
+
|
|
88
|
+
### Features
|
|
89
|
+
- Login to dropcountr.com with email/password
|
|
90
|
+
- Fetch usage data for service connections with flexible date ranges
|
|
91
|
+
- Parse usage data into clean Python objects
|
|
92
|
+
- Handle authentication state and session management
|
|
93
|
+
- Support for different time periods (day, hour)
|
|
94
|
+
- Irrigation and leak detection data parsing
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Release Guidelines
|
|
99
|
+
|
|
100
|
+
### Version Numbers
|
|
101
|
+
- **Major (X.y.z)**: Breaking changes to public API
|
|
102
|
+
- **Minor (x.Y.z)**: New features, backward compatible
|
|
103
|
+
- **Patch (x.y.Z)**: Bug fixes, backward compatible
|
|
104
|
+
|
|
105
|
+
### Change Categories
|
|
106
|
+
- **Added**: New features
|
|
107
|
+
- **Changed**: Changes in existing functionality
|
|
108
|
+
- **Deprecated**: Soon-to-be removed features
|
|
109
|
+
- **Removed**: Removed features
|
|
110
|
+
- **Fixed**: Bug fixes
|
|
111
|
+
- **Security**: Security improvements
|
|
112
|
+
|
|
113
|
+
### Release Process
|
|
114
|
+
1. Update CHANGELOG.md with new version section
|
|
115
|
+
2. Move items from [Unreleased] to new version section
|
|
116
|
+
3. Update version in pyproject.toml
|
|
117
|
+
4. Create git tag with version number
|
|
118
|
+
5. Create GitHub release with changelog notes
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# PyDropCountr - Python Library for DropCountr.com
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
This is a Python library for interacting with dropcountr.com, providing easy access to water usage data through clean Python objects.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
- User authentication with login/logout
|
|
8
|
+
- Service connection management (list and get details)
|
|
9
|
+
- Water usage data fetching with date ranges
|
|
10
|
+
- Structured data objects (ServiceConnection, UsageData, UsageResponse)
|
|
11
|
+
- Date parsing and validation
|
|
12
|
+
- Session management with rack.session cookies
|
|
13
|
+
|
|
14
|
+
## Development Setup
|
|
15
|
+
- This project uses `uv` for dependency management
|
|
16
|
+
- Python 3.12+ required
|
|
17
|
+
- Dependencies: requests>=2.31.0
|
|
18
|
+
- Run tests with: `uv run python test_login.py`
|
|
19
|
+
- Run linting with: `uv run ruff check` (when configured)
|
|
20
|
+
|
|
21
|
+
## Usage Examples
|
|
22
|
+
|
|
23
|
+
### Basic Login
|
|
24
|
+
```python
|
|
25
|
+
from pydropcountr import DropCountrClient
|
|
26
|
+
|
|
27
|
+
client = DropCountrClient()
|
|
28
|
+
success = client.login('your@email.com', 'yourpassword')
|
|
29
|
+
if success:
|
|
30
|
+
print("Logged in successfully!")
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### List Service Connections
|
|
34
|
+
```python
|
|
35
|
+
# Get all service connections for the authenticated user
|
|
36
|
+
services = client.list_service_connections()
|
|
37
|
+
if services:
|
|
38
|
+
print(f"Found {len(services)} service connections:")
|
|
39
|
+
for service in services:
|
|
40
|
+
print(f" {service.id}: {service.name} at {service.address}")
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Get Service Connection Details
|
|
44
|
+
```python
|
|
45
|
+
# Get details for a specific service connection
|
|
46
|
+
service = client.get_service_connection(1064520)
|
|
47
|
+
if service:
|
|
48
|
+
print(f"Service: {service.name}")
|
|
49
|
+
print(f"Address: {service.address}")
|
|
50
|
+
print(f"Account: {service.account_number}")
|
|
51
|
+
print(f"Status: {service.status}")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Fetch Usage Data
|
|
55
|
+
```python
|
|
56
|
+
from datetime import datetime
|
|
57
|
+
|
|
58
|
+
# Get daily usage data for June 2025 using Python datetime objects
|
|
59
|
+
usage = client.get_usage(
|
|
60
|
+
service_connection_id=1258809,
|
|
61
|
+
start_date=datetime(2025, 6, 1), # Python datetime object
|
|
62
|
+
end_date=datetime(2025, 6, 30, 23, 59, 59), # Python datetime object
|
|
63
|
+
period='day' # Can be 'day', 'hour', etc.
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
if usage:
|
|
67
|
+
print(f"Total records: {usage.total_items}")
|
|
68
|
+
for record in usage.usage_data[:3]:
|
|
69
|
+
print(f"{record.start_date.date()}: {record.total_gallons} gallons")
|
|
70
|
+
|
|
71
|
+
# Alternative: You can still use ISO datetime strings
|
|
72
|
+
usage = client.get_usage(
|
|
73
|
+
service_connection_id=1258809,
|
|
74
|
+
start_date='2025-06-01T00:00:00.000Z',
|
|
75
|
+
end_date='2025-06-30T23:59:59.000Z',
|
|
76
|
+
period='day'
|
|
77
|
+
)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## API Information
|
|
81
|
+
- Login URL: https://dropcountr.com/login
|
|
82
|
+
- Login method: POST with email and password parameters
|
|
83
|
+
- Service connections list: https://dropcountr.com/api/service_connections
|
|
84
|
+
- Service connection details: https://dropcountr.com/api/service_connections/{id}
|
|
85
|
+
- Usage API: https://dropcountr.com/api/service_connections/{id}/usage
|
|
86
|
+
- Authentication: rack.session cookie must be maintained for subsequent requests
|
|
87
|
+
- API version: application/vnd.dropcountr.api+json;version=2
|
|
88
|
+
|
|
89
|
+
## Data Classes
|
|
90
|
+
- `ServiceConnection`: Service connection details including ID, name, address, account info
|
|
91
|
+
- `UsageData`: Individual usage record with gallons, irrigation data, leak detection
|
|
92
|
+
- `UsageResponse`: Full API response with usage data array and metadata
|
|
93
|
+
- All classes include proper type hints and parsing utilities
|
|
94
|
+
|
|
95
|
+
## Development Notes
|
|
96
|
+
- Keep authentication session state for API calls
|
|
97
|
+
- Implement proper error handling for login failures and API errors
|
|
98
|
+
- Return data as clean Python objects with type safety
|
|
99
|
+
- **Service Discovery**: Use `list_service_connections()` to discover available service connection IDs
|
|
100
|
+
- **Date Parameters**: The library accepts both Python `datetime` objects (recommended) and ISO 8601 datetime strings
|
|
101
|
+
- When using datetime objects, the library automatically converts them to the required API format
|
|
102
|
+
- Timezone handling: datetime objects are converted to UTC with 'Z' suffix for API compatibility
|
|
103
|
+
|
|
104
|
+
## Changelog Management
|
|
105
|
+
|
|
106
|
+
### Using CHANGELOG.md
|
|
107
|
+
This project maintains a comprehensive CHANGELOG.md file following [Keep a Changelog](https://keepachangelog.com/) format:
|
|
108
|
+
|
|
109
|
+
**When to update the changelog:**
|
|
110
|
+
- Every significant change to the library or CLI
|
|
111
|
+
- New features, bug fixes, API changes, or breaking changes
|
|
112
|
+
- Before each release to move items from [Unreleased] to a version section
|
|
113
|
+
|
|
114
|
+
**How to update the changelog:**
|
|
115
|
+
1. Add new changes under the `[Unreleased]` section
|
|
116
|
+
2. Use appropriate categories: Added, Changed, Deprecated, Removed, Fixed, Security
|
|
117
|
+
3. Write clear, user-focused descriptions of changes
|
|
118
|
+
4. Include relevant details like new CLI flags, API changes, or breaking changes
|
|
119
|
+
|
|
120
|
+
**Release process:**
|
|
121
|
+
1. Update CHANGELOG.md with new version section
|
|
122
|
+
2. Move items from [Unreleased] to the new version section with date
|
|
123
|
+
3. Update version number in pyproject.toml
|
|
124
|
+
4. Create git tag with version number: `git tag v0.x.x`
|
|
125
|
+
5. Create GitHub release with changelog notes
|
|
126
|
+
|
|
127
|
+
**Example changelog entry:**
|
|
128
|
+
```markdown
|
|
129
|
+
## [Unreleased]
|
|
130
|
+
|
|
131
|
+
### Added
|
|
132
|
+
- New CLI flag `--format` for output formatting
|
|
133
|
+
- Support for JSON output in CLI
|
|
134
|
+
|
|
135
|
+
### Fixed
|
|
136
|
+
- Authentication timeout handling
|
|
137
|
+
- Memory leak in session management
|
|
138
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Matthew Colyer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|