
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Gupshup Whatsapp API as a Gem in Ruby for easier integration
Add this line to your application's Gemfile:
gem 'gupshup_whatsapp'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install gupshup_ruby
To test, refer to Testing
Use the Gupshup API docs to construct the payload for a message type.
Refer to gem documentation for the methods and their required parameters
payload = {
:type => "image",
:originalUrl => 'https://www.buildquickbots.com/whatsapp/media/sample/jpg/sample01.jpg',
:previewUrl => 'https://www.buildquickbots.com/whatsapp/media/sample/jpg/sample02.jpg',
:caption => 'Test Image'
}
payload = {
:isHSM => false,
:type => "text",
:text => 'Test message'
}
payload = { :type => 'list',
:title => 'Rspec tests',
:body => 'This is rspec testing body',
:globalButtons => [{ :type => 'text', :title => 'Test List' }],
:items =>[
{ "title": "first Section", "subtitle": "first Subtitle", "options": [
{ "type": "text", "title": "section 1 row 1", "description": "first row of first section description", "postbackText": "section 1 row 1 postback payload" },
{ "type": "text", "title": "section 1 row 2", "description": "second row of first section description", "postbackText": "section 1 row 2 postback payload" },
{ "type": "text", "title": "section 1 row 3", "description": "third row of first section description", "postbackText": "section 1 row 3 postback payload" } ]
},
{
"title": "second section", "subtitle": "second Subtitle", "options": [
{ "type": "text", "title": "section 2 row 1", "description": "first row of second section description", "postbackText": "section 1 row 3 postback payload" }
]
}
]
}
payload = {
'type': 'sticker',
'url': url
}
payload = {
:type => "video",
:url => 'https://www.buildquickbots.com/whatsapp/media/sample/video/sample01.mp4',
:caption => 'Test Video'
}
payload = {
:type => "file",
:url => 'https://www.buildquickbots.com/whatsapp/media/sample/pdf/sample01.pdf',
:filename => 'Test file'
}
payload = {
:type => "quick_reply",
:content => {"type":"text", "text": "Fave book?", "caption": "Malatesta edition"},
:options => [{ "title": "Anarchy"}, {"title": "Anarchists vs plague"}]}
payload = {
:type => "audio",
:url => 'https://www.buildquickbots.com/whatsapp/media/sample/audio/sample01.mp3'
}
payload = {
:type => "location",
:longitude => 43.43,
:latitude => 33.34,
:name => "Test name",
:address => "Test address"
}
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('9163xxxxxxxx', payload)
To run tests, set the following environmental variables:
export GUPSHUP_DESTINATION_PHONE=
export GUPSHUP_APP=
export GUPSHUP_APP_APIKEY=
export GUPSHUP_API_VERSION=2
And the run:
rspec --format doc
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.
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.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the GupshupRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that gupshup_whatsapp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.