Skip to content

Conversation

@tombii
Copy link

@tombii tombii commented Oct 17, 2025

Summary

This PR adds support for GatewayAPI SMS notifications to Apprise.

Features

  • Send SMS notifications via GatewayAPI REST API (https://gatewayapi.com)
  • Support for multiple target phone numbers
  • Optional sender/from parameter for custom branding
  • Full URL parsing and reconstruction
  • Proper phone number validation

Implementation Details

  • Plugin: apprise/plugins/gatewayapi.py
  • Tests: tests/test_plugin_gatewayapi.py
  • URL Format: gatewayapi://{apikey}@{phone_numbers}
  • Optional Parameters: from (sender name/number), key (alias for API key), to (additional targets)

Testing

Comprehensive test coverage includes:

  • ✅ URL parsing with various formats
  • ✅ Invalid API key and phone number handling
  • ✅ Multiple target phone numbers
  • ✅ Sender parameter verification
  • ✅ HTTP response code handling (200, 201, 4xx, 5xx)
  • ✅ Request exception handling
  • ✅ Privacy URL masking
  • ✅ Edge cases (invalid numbers, no targets, etc.)

Test Results

  • All code formatted with ruff
  • No linting issues detected
  • Plugin automatically registered via NotificationManager

Example Usage

import apprise

# Initialize
apobj = apprise.Apprise()

# Add GatewayAPI notification
apobj.add('gatewayapi://your_api_key@15551234567')

# With sender
apobj.add('gatewayapi://your_api_key@15551234567?from=MyApp')

# Multiple targets
apobj.add('gatewayapi://your_api_key@15551234567/15559876543')

# Send notification
apobj.notify('Message body', title='Title')

🤖 Generated with Claude Code

This commit adds support for GatewayAPI SMS notifications with comprehensive test coverage.

Features:
- Send SMS notifications via GatewayAPI REST API
- Support for multiple target phone numbers
- Optional sender/from parameter for branding
- Full URL parsing and reconstruction
- Proper phone number validation

Testing:
- Comprehensive URL parsing tests
- Edge case handling (invalid numbers, multiple targets)
- HTTP response code handling (200, 201, 4xx, 5xx)
- Request exception handling
- Privacy URL masking

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@codecov
Copy link

codecov bot commented Oct 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.65%. Comparing base (74d5ad2) to head (fbf8b57).

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #1430    +/-   ##
========================================
  Coverage   99.65%   99.65%            
========================================
  Files         174      175     +1     
  Lines       22554    22654   +100     
  Branches     3587     3605    +18     
========================================
+ Hits        22476    22576   +100     
  Misses         70       70            
  Partials        8        8            
Files with missing lines Coverage Δ
apprise/plugins/gatewayapi.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines 172 to 175
payload = {
"message": body,
"recipients.0.msisdn": int(target),
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great start! but when i visit https://gatewayapi.com/docs/apis/rest/#sending-sms-messages, it seems like the payload doesn't align. You're missing quit a few fields. Perhaps you're a developer of the system and know of some un-documented approaches?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was basing it on the Simple SMS API (HTTP) https://gatewayapi.com/docs/apis/simple/

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough; get it working for you and I can help you with test cases.

tombii and others added 2 commits October 22, 2025 16:24
- Improve test coverage from 89.79% to 100%
- Add sender field validation (alphanumeric 1-11 chars or numeric 1-15 digits)
- Add tests for URL parsing, privacy mode, empty targets, and sender validation
- Fix test case expectation for mixed valid/invalid targets

Test improvements:
- test_plugin_gatewayapi_url_parsing: Tests API key in password field, key query param, 'to' param, URL privacy mode
- test_plugin_gatewayapi_length_method: Tests __len__() with various target configurations
- test_plugin_gatewayapi_url_identifier: Tests url_identifier property
- test_plugin_gatewayapi_empty_targets: Tests notification with no targets
- test_plugin_gatewayapi_sender_validation: Comprehensive sender field validation tests

Security enhancements:
- Validates sender against GatewayAPI specifications
- Prevents injection via sender field
- Gracefully handles invalid senders with warnings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…uest

Updated the send() method to comply with GatewayAPI's Simple SMS API
specification by sending all recipients in a single API request using
array indexing (recipients.0.msisdn, recipients.1.msisdn, etc.) instead
of making separate API calls for each recipient.

Benefits:
- Reduced API calls from N (one per recipient) to 1 (single batched request)
- Improved efficiency for bulk messaging
- Better rate limit utilization
- Full conformance with GatewayAPI Simple SMS API specification

Updated tests to verify batching behavior and maintained 100% test coverage.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants