Konekt
A Ruby (and optionally Rails) library to interact with the Konekt cloud.
Current features:
- Webhook to receive messages - "Custom Webhook Url (your own App)"
- Automatic authentication to webhook key
- Decodes payload JSON
- Decodes data base64
- Basically, all data passed in to Konekt is passed out as an easy to consume object - per tag, where ever in your app you wish to subscribe.
Installation
Add this line to your application's Gemfile:
gem 'konekt'
And then execute:
$ bundle
Or install it yourself as:
$ gem install konekt
Setup
The endpoint defaults to '/konekt_processor'. If you're app is at https://example.com/
then you should set your webhook URL in Konekt to https://example.com/konekt_processor
ENV['KONEKT_WEBHOOK_KEY']
should be set to to the "Webhook Key" value from the Konekt applcation for this webhook.
Or you can override these in configuration:
# In an appropriate initializer
Konekt.configure do |config|
config.mount_point = '/some/other/path'
config.auth_token = ENV['KONEKT_WEBHOOK_KEY']
end
Rack/Sinatra:
# config.ru
require 'konekt/middleware'
use Konekt::Middleware
Rails: This middleware is registered automatically.
Subscribing to Tags
Subscribe to the tags you care about:
Konekt.subscribe 'parcel_shipped' do |event|
puts event
# Do something with event
# You probably want to fire a background task
end
In Rails this could live at config/initalizers/konekt.rb
Problems?
This is pretty new and Konekt is pretty new too. Please raise issues or send PRs!
Contributing
- Fork it ( https://github.com/[my-github-username]/konekt/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request