Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pip install -e ".[dev]"

- name: Lint with ruff
run: |
ruff check src/ tests/
ruff format --check src/ tests/

- name: Type check with mypy
run: mypy src/

- name: Run tests
run: pytest --cov=lansweeper_helpdesk --cov-report=xml -v

- name: Upload coverage
if: matrix.python-version == '3.12'
uses: codecov/codecov-action@v4
with:
file: coverage.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish to PyPI

on:
release:
types: [published]

permissions:
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install build tools
run: pip install build

- name: Build package
run: python -m build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

publish:
needs: build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
dist/
build/
*.egg-info/
*.egg

# Virtual environments
.venv/
venv/
env/

# IDE
.idea/
.vscode/
*.swp
*.swo

# Type checking / linting caches
.mypy_cache/
.ruff_cache/
.pytest_cache/

# Coverage
htmlcov/
.coverage
.coverage.*
coverage.xml

# Environment / secrets
.env
config/config.json

# OS
.DS_Store
Thumbs.db
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/).

## [0.1.0] - Unreleased

Initial release as a proper Python package.

### Added

- Installable package via `pip install lansweeper-helpdesk`.
- Full type annotations on all public methods and parameters.
- Custom exception hierarchy: `HelpdeskError`, `APIError`, `ConfigurationError`, `TicketNotFoundError`.
- `TicketState` and `NoteType` enums for common API values.
- `py.typed` marker for PEP 561 type checker support.
- Comprehensive test suite using pytest and responses.
- CI pipeline (GitHub Actions) with testing across Python 3.10–3.13, ruff linting, and mypy type checking.
- PyPI publishing workflow via GitHub Releases using trusted publishers (OIDC).

### Changed

- **BREAKING**: Renamed `type` parameter to `note_type` in `add_note()` and `ticket_type` in `edit_ticket()` to avoid shadowing the Python builtin.
- **BREAKING**: Renamed `search_ticket()` to `search_tickets()` with snake_case parameters (`from_user_id`, `agent_id`, `ticket_type`, `max_results`, `min_date`, `max_date`). All parameters are now keyword-only.
- **BREAKING**: API errors now raise `APIError` instead of returning `None`.
- **BREAKING**: `get_ticket_history()` now returns a `list[dict]` of parsed notes instead of a formatted JSON string.
- Replaced all `print()` calls with `logging` — the SDK no longer writes to stdout.
- `cert_path` is now optional (defaults to standard certificate verification).
- Internal request method renamed from `make_request` to `_request`.

### Removed

- `pretty_print_response()` — libraries should not print to stdout; use `json.dumps(response, indent=2)` if needed.
- `usage_decorator` — replaced by proper type annotations and exception handling.
- Hard-coded `time.sleep(1)` in `get_ticket_history()`.
57 changes: 57 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Contributing

Contributions are welcome! Here's how to get started.

## Setup

1. Fork and clone the repository:

```bash
git clone https://github.com/<your-username>/Lansweeper.Helpdesk-Python.git
cd Lansweeper.Helpdesk-Python
```

2. Create a virtual environment and install dev dependencies:

```bash
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
pip install -e ".[dev]"
```

## Development Workflow

### Running Tests

```bash
pytest --cov
```

All new features and bug fixes should include tests.

### Linting & Formatting

```bash
ruff check src/ tests/
ruff format src/ tests/
```

### Type Checking

```bash
mypy src/
```

## Submitting Changes

1. Create a feature branch from `main`.
2. Make your changes with clear, descriptive commits.
3. Ensure all tests pass, linting is clean, and type checking succeeds.
4. Open a pull request against `main`.

## Code Style

- Follow existing patterns in the codebase.
- Use type annotations on all public functions and methods.
- Use `logging` (never `print()`) for any debug or status output.
- Keep docstrings up to date when modifying public API methods.
Loading