Smsc_ru - Ruby API Client for smsc.ru
Installation
Add this line to your application's Gemfile:
gem 'smsc_ru'
And then execute:
$ bundle
Or install it yourself as:
$ gem install smsc_ru
Configuration
Smsc.configure do |config|
# Mandatory attributes, creating client fail, if it not specified
config.login = 'your_login'
config.password = 'your_password' # password or MD5 hash
# Optional configuration
# default: smsc.ru
config.host = 'custom_endpoint'
# default: true
config.ssl = false
# default Logger.new(STDOUT)
config.logger = CustomerLogger.new
# default utf-8
config.encoding = 'windows-1251
end
Or via constructor params:
client = Smsc::Client.new do |client|
client.login = 'custom loging'
client.password = 'custom password'
end
Usage
Usage example:
client = Smsc::Client.new
# send one sms
client.send_sms("79999999999", "Password: 123")
# send multiple sms
client.send_sms("79999999999,78888888888", "Password: 123")
# raise error on problem
client.send_sms("79999", "Ваш пароль: 123") # => error Smsc::BadRequest.new('invalid phone')
# add additional parameters
client.send_sms("79999999999,78888888888", "Password: 123", translit: 1)
# Check sms status
client.status(12345, "79999999999") # => Smsc::Status model with attributes
# Receive balance
balance = client.balance
Gem wrap response in models and raise errors on problems
Development
After checking out the repo, run bin/setup
to install dependencies. You can also run bin/console
for an interactive prompt that will allow you to experiment.
SMSC_LOGIN=your_login SMSC_PASSWORD=your_password bin/console
After starting console just type
client = Smsc::Client.new
client.balance
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
- Fork it ( https://github.com/SPBTV/smsc_ru )
- Create your feature branch (
git checkout -b feature/my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin feature/my-new-feature
) - Create a new Pull Request
License
Copyright 2015 SPB TV AG
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.