SmsPilot API v1 client
Simple wrapper around SMS pilot API v1. Version 1 because it returns more data within its standard response.
Installation
from RubyGems:
gem "sms-pilot-api-v1"
from GitHub:
gem "sms-pilot-api-v1", git: "https://github.com/sergeypedan/sms-pilot-api-v1.git"
Playground
Test sending SMS from console with a test API key (find it at the end of this page):
cd $(bundle info sms-pilot-api-v1 --path)
bin/console
Usage
Initialize
require "sms_pilot"
key = "XXXXXXXXXXXXYYYYYYYYYYYYZZZZZZZZXXXXXXXXXXXXYYYYYYYYYYYYZZZZZZZZ"
client = SmsPilot::Client.new(api_key: key)
client = SmsPilot::Client.new(api_key: key, locale: :en)
Method documentation at RubyDoc.
Before sending
There are a bunch of methods describing the state of affairs:
client.api_key
client.balance
client.broadcast_id
client.error
client.phone
client.rejected?
client.response_body
client.response_data
client.response_headers
client.response_status
client.sender_blocked?
client.sms_cost
client.sms_sent?
client.sms_status
client.url
before the request is sent they return obvious nils or empty structures; after the request they are populated with data.
See structured documentation for those methods at RubyDoc.
Sending SMS
client.send_sms("+7 (902) 123-45-67", "Привет, мир!")
client.send_sms("+7 (902) 123-45-67", "Привет, мир!", "ФССПРФ")
Returns result of sms_sent?
, so it’s either true
or false
.
Method documentation at RubyDoc.
Sending SMS succeeded
client.api_key
client.balance
client.broadcast_id
client.error
client.phone
client.rejected?
client.response_body
client.response_data
client.response_headers
client.response_status
client.sender_blocked?
client.sms_cost
client.sms_sent?
client.sms_status
client.url
Sending SMS failed (but HTTP request succeeded)
client.api_key
client.balance
client.broadcast_id
client.error
client.phone
client.rejected?
client.response_body
client.response_data
client.response_headers
client.response_status
client.sender_blocked?
client.sms_cost
client.sms_sent?
client.sms_status
client.url
HTTP request failed
client.api_key
client.balance
client.broadcast_id
client.error
client.phone
client.rejected?
client.response_body
client.response_data
client.response_headers
client.response_status
client.sender_blocked?
client.sms_cost
client.sms_sent?
client.sms_status
client.url
SMS pilot API docs
Test API key
https://smspilot.ru/apikey.php
"XXXXXXXXXXXXYYYYYYYYYYYYZZZZZZZZXXXXXXXXXXXXYYYYYYYYYYYYZZZZZZZZ"
API response examples
SMS sent:
{
"balance": "11908.50",
"cost": "1.68",
"send": [
{ "server_id": "10000", "phone": "79021234567", "price": "1.68", "status": "0" }
]
}
SMS rejected:
{
"error": {
"code": "400",
"description": "User not found",
"description_ru": "Пользователь не найден"
}
}
Documentation
See structured documentation at RubyDoc.
Roadmap
- Switch to POST to escape 1024 symbolos GET request limit
- Support passing
sender
to the API - Switch to result object pattern
- Проверка статусов SMS
- Проверка баланса
- Информация о пользователе