Commit Graph

21 Commits

Author SHA1 Message Date
bohd4nx f37a4ab985 feat: implement search_auctions method for Fragment marketplace; add AuctionsResult type; enhance topup_ton example and tests 2026-03-25 17:40:02 +02:00
bohd4nx dfe7bb4140 feat: implement recharge_ads method for Telegram Ads account funding; add associated result type and example; enhance tests for validation and success cases 2026-03-25 00:57:31 +02:00
bohd4nx 327ca35190 feat: update README and pyproject description; enhance test docstrings for clarity and consistency 2026-03-21 17:51:19 +02:00
bohd4nx 6e4d4da740 feat: add anonymous number management methods; implement get_login_code, toggle_login_codes, and terminate_sessions with associated results and error handling 2026-03-21 17:43:58 +02:00
bohd4nx ab8d463d54 feat: add unit tests for balance checks, giveaway stars, and premium methods; validate float inputs for winners and amounts 2026-03-21 17:18:56 +02:00
bohd4nx 25d70a77ed feat: implement client.call() method for raw Fragment API requests; add example and unit tests 2026-03-21 16:45:52 +02:00
bohd4nx c7b6c6c933 feat: add comprehensive unit tests for FragmentClient methods; include shared test constants 2026-03-21 16:30:44 +02:00
bohd4nx 2d1a119768 feat: update purchase and giveaway methods; improve header management and add example scripts 2026-03-21 16:16:14 +02:00
bohd4nx 902b692dcb Refactor methods for Telegram Premium and Stars giveaways
- Added new methods for handling giveaways: `giveaway_premium` and `giveaway_stars`.
- Refactored existing purchase methods into separate files: `purchase_premium.py` and `purchase_stars.py`.
- Removed old premium and stars methods from the codebase.
- Updated `__init__.py` to include new giveaway methods in the public API.
- Introduced new result types for giveaways: `PremiumGiveawayResult` and `StarsGiveawayResult`.
- Updated constants for new giveaway pages.
- Enhanced error handling for configuration and user validation in giveaway methods.
- Updated tests to cover new functionality and refactored existing tests to match new method locations.
2026-03-21 16:05:38 +02:00
bohd4nx 3e14a01c92 refactor: harden client, clean tests, and fix timeouts
- Security & validation: tighten hash regex, add HTTP timeouts to all
  requests, pass client.timeout through get_fragment_hash and AsyncClient
- Constants: move all constants to types/constants.py; remove re-exports
  from types/__init__.py; add DEFAULT_TIMEOUT, REQUIRED_COOKIE_KEYS
- FragmentClient: add timeout param (default 30 s); async-context-manager
  support; remove WALLET_CLASSES from public API
- Exceptions: remove dead INVALID_USERNAME constant (Fragment validates
  server-side); keep full hierarchy intact
- Tests: add 006_test_methods_mock.py (6 mock tests for all 3 methods);
  DRY-refactor 004_test_balance.py (_patch_wallet context manager);
  clean up 005_test_methods.py (remove fragile network test, rename tests)
- Examples: switch all 4 examples to async-with; align error messages;
  replace %-format with f-strings
- README: rewrite usage section with single comprehensive async-with
  example covering all 3 methods and full exception hierarchy
- CI: add mypy step to lint job; add pytest-mock and mypy to dev deps;
  set FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 on all jobs; fix COOKIES_JSON
  to job-level env var
2026-03-20 20:16:43 +02:00
bohd4nx c5edfad06f feat: add context manager support to FragmentClient; update README and tests 2026-03-16 19:21:43 +02:00
bohd4nx 041081b919 feat: add API key validation and corresponding error handling; update tests for validation 2026-03-15 23:01:37 +02:00
bohd4nx d8f0240807 feat: add wallet management features and enhance error handling; update tests and examples 2026-03-15 22:41:52 +02:00
bohd4nx 8135a9da7e Refactor FragmentAPI to pyfragment
- Renamed the package from `fragmentapi` to `pyfragment` across all modules and tests.
- Removed the old wallet utility functions and replaced them with new implementations.
- Updated the `pyproject.toml` to reflect the new package name and repository links.
- Adjusted all import statements in tests to use the new package name.
- Implemented new methods for gifting Telegram Premium, Stars, and topping up TON balance.
- Added exception handling for various error scenarios in the API interactions.
- Created new utility functions for handling HTTP requests and decoding payloads.
- Established a clear structure for types and constants used throughout the library.
2026-03-15 22:07:01 +02:00
bohd4nx 7f269d9a87 refactor: rename error classes for consistency and clarity; update related code and tests 2026-03-15 22:03:32 +02:00
bohd4nx d2d046a2b9 refactor: restructure as installable PyPI package
- Rename app/ → fragmentapi/ for proper package naming
- Add FragmentClient class with gift_premium, gift_stars, topup_ton methods
- Restructure core/ → types/ (exceptions, results, constants)
- Merge utils/hash.py into utils/client.py
- Replace _version.py with importlib.metadata
- Add input validation with min/max bounds
- Add unit tests: decode, client init/cookies
- Rename 002_test_hash → 003_test_hash
- Clean up pyproject.toml: pin deps, production classifiers
2026-03-15 21:03:03 +02:00
bohd4nx 4e017cb7a1 refactor: update methods to include show_sender parameter and clean up tests 2026-03-14 01:34:51 +02:00
bohd4nx 8cf57b58b7 refactor: enhance test workflow and integration tests with cookies handling and configuration checks 2026-03-08 03:58:07 +02:00
bohd4nx 7f3c3ea1c3 refactor: update API key source in .env.example and enhance README with badges and feature descriptions
feat: improve logging levels for HTTP clients and add detailed logging in premium and stars purchase methods
chore: remove unused transaction utility and adjust wallet processing logic
test: add end-to-end integration test for buying Stars
2026-03-05 06:26:49 +02:00
bohd4nx efcdda6b74 refactor: migrate to tonutils 2.0.0 and restructure codebase
- Migrate from tonutils 0.5.x to 2.0.0 API:
  - ToncenterClient → TonapiClient with NetworkGlobalID
  - tonutils.client → tonutils.clients
  - tonutils.wallet → tonutils.contracts.wallet
  - pub_key.as_hex property, wallet.balance nanotons
  - async with client context manager

- Centralize TON client init into initialize_ton_client() in wallet.py
- Move process_transaction logic into wallet.py, transaction.py re-exports
- Add WALLET_VERSION config (V4R2/V5R1, default V5R1)
- Add WALLET_CLASSES and SUPPORTED_WALLET_VERSIONS to constants.py
- Restore balance check before broadcasting
- Wait for seqno confirmation after transfer (120×2s) to prevent duplicate seqno

- Fix Fragment hash fetching: use browser navigation headers
- Remove accept-encoding from BASE_HEADERS (httpx handles decompression)
- Add cookies.example.json template
- Add cookies.json to .gitignore
2026-03-05 05:47:27 +02:00
bohd4nx f57f8271c3 test: add pytest test files (were missing from previous commit) 2026-03-05 04:18:55 +02:00