# GupshupRuby [![Gem Version](https://badge.fury.io/rb/gupshup_whatsapp.svg)](https://badge.fury.io/rb/gupshup_whatsapp) Gupshup Whatsapp API as a Gem in Ruby for easier integration ## Installation Add this line to your application's Gemfile: ```ruby gem 'gupshup_whatsapp' ``` And then execute: $ bundle install Or install it yourself as: $ gem install gupshup_ruby To test, refer to [Testing](#testing) ## Usage Use the Gupshup API [docs](https://www.gupshup.io/developer/docs/bot-platform/guide/whatsapp-api-documentation) to construct the payload for a message type. For example: #### Image payload: ``` payload = { :type => "image", :originalUrl => 'https://www.chatwoot.com/docs/img/logo.png', :previewUrl => 'https://www.chatwoot.com/docs/img/logo.png' } ``` #### Text Payload ``` payload = { :isHSM => false, :type => "text", :text => 'Hi Hello' } ``` #### List Payload ``` payload = { :isHSM => false, :type => "text", :text => 'Hi Hello' } ``` #### Sticker Payload ``` payload = { 'type': 'sticker', 'url': url } ``` #### Videos Payload ``` payload = { :isHSM => false, :type => "text", :text => 'Hi Hello' } ``` #### Files Payload ``` payload = { :isHSM => false, :type => "text", :text => 'Hi Hello' } ``` #### Text Payload ``` payload = { :isHSM => false, :type => "text", :text => 'Hi Hello' } ``` #### Audio Payload ``` payload = { :isHSM => false, :type => "text", :text => 'Hi Hello' } ``` #### Location Payload ``` payload = { :isHSM => false, :type => "text", :text => 'Hi Hello' } ``` After this, run the following commands in your code after replacing the credentials and phone number: ``` g = Gupshup::WhatsApp.new(app, apikey, phone_number, version='2') g.send('916383467769', payload) ``` ## Testing To run tests, set the following environmental variables: ```shell export GUPSHUP_DESTINATION_PHONE= export GUPSHUP_APP= export GUPSHUP_APP_APIKEY= export GUPSHUP_API_VERSION=2 ``` And the run: ```shell rspec --format doc ``` ## 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](https://rubygems.org). ## Contributing Bug reports and pull requests are welcome on GitHub at https://gitlab.com/thundersp/gupshup_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/gupshup_ruby/blob/master/CODE_OF_CONDUCT.md). ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). ## Code of Conduct Everyone interacting in the GupshupRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/gupshup_ruby/blob/master/CODE_OF_CONDUCT.md).