Skip to content
Simple api client for smsc.ru
Ruby Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
lib
spec
.codeclimate.yml
.gitignore
.rspec
.rubocop.yml
.travis.yml
CHANGELOG.md
Gemfile
LICENSE.txt
README.md
Rakefile
smsc.gemspec

README.md

Gem Version Build Status Test Coverage Code Climate Inline docs Hex.pm

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") # => raise 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

  1. Fork it ( https://github.com/SPBTV/smsc_ru )
  2. Create your feature branch (git checkout -b feature/my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/my-new-feature)
  5. 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.

You can’t perform that action at this time.