Coder Social home page Coder Social logo

msg91-ruby's Introduction

MSG91

Send your next message via MSG91 in ruby.

Installation

Add this line to your application's Gemfile:

gem 'msg91', git: 'git://github.com/MSG91/msg91-ruby.git'

And then execute:

$ bundle

Usage

Initialize the API client with your auth key.

api_client = MSG91::Client.new('your_auth_key')

Basics

  • Check route balance
api_client.check_balance(Message::ROUTES::PROMOTIONAL) #=> 129
  • Check if authkey is valid
api_client.valid? #=> true

Send messages

message = api_client.messages.new(phones: [9876543210, 9548741230], sender: 'TESTER')
message.content = 'The quick brown fox jumps over the lazy dog'
message.route = Message::ROUTES::PROMOTIONAL

message.send

Manage Phonebook

Create Group
group = api_client.phonebook.groups.new('new_group')
group.save

# OR

api_client.phonebook.groups.create('new_group')
List Groups
api_client.phonebook.groups.list
Delete Group
group.delete

# OR

api_client.phonebook.delete_group(group_id)
Create Contact
contact = group.contacts.new(9876543210)
contact.name('Test User')
contact.save

# OR

group.contacts.create(phone: 9876543210, name: 'Test User')
Update Contact
contact.phone = 9548741230
contact.save

# OR

api_client.phonebook.update_contact(id, phone: 9548741230, name: 'Another User')
Delete Contact
contact.delete

# OR

api_client.phonebook.delete_contact(contact_id)
List Contacts
group.contacts.list

Manage Resellers

Add Client
client = api_client.resellers.clients.new
client.full_name = 'My new client'
client.user_mobile_number = 9876543210
client.save

# OR

client = api_client.resellers.clients.create(full_name: 'My new client', ...)
List Clients
client.resellers.clients.list
Update Client Balance
client.debit(sms: 200, price: 0.8, route: Message::ROUTES::PROMOTIONAL, description: 'Test message')
client.credit(sms: 200, price: 0.75, route: Message::ROUTES::PROMOTIONAL, description: 'Test message')

# OR

api_client.resellers.update_client_balance(client_id, sms: 200, price: 0.8, route: Message::ROUTES::PROMOTIONAL, direction: Reseller::TRANSACTIONS::DEBIT, description: 'Test message')
api_client.resellers.update_client_balance(client_id, sms: 200, price: 0.75, route: Message::ROUTES::PROMOTIONAL, direction: Reseller::TRANSACTIONS::CREDIT, description: 'Test message')
Change Client Password
client.change_password('new_password')
# OR
api_client.resellers.change_client_password(client_username, new_password: 'new_password')

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

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

Bug reports and pull requests are welcome on GitHub at https://github.com/MSG91/msg91-ruby/issues.

License

The gem is available as open source under the terms of the MIT License.

msg91-ruby's People

Contributors

31piy avatar dependabot[bot] avatar rwalkover avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ysavings

msg91-ruby's Issues

Outdated repo

This repo shows the code and instructions for the 0.1.0 version of the gem, while the one available at rubygems is 0.2.2.

That makes using this gem unintuitive, as we must either purposefully install v 0.1.0 or dig the readme from the downloaded gem and use those instructions.

The latest version of the source code should be uploaded here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.