Add spree_hub to your Gemfile:
gem 'spree_hub', github: 'spree/hub_gem'
Bundle your dependencies and run the installation generator:
bundle
bundle exec rails g spree_hub:install
First bundle your dependencies, then run rake
. rake
will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using rake test_app
.
bundle
bundle exec rake
When testing your applications integration with this extension you may use it's factories. Simply add this require statement to your spec_helper:
require 'spree_hub/factories'
Note: this will be abstracted soon in Spree::Hub::Client
Add the hub credentials to config/initializers/spree.rb
:
Spree::Hub::Config[:hub_store_id] = "34werwerwer"
Spree::Hub::Config[:hub_token] = "sdfsfddfdss"
Add the push after_commit
to Spree::Order
.
Spree::Order.after_commit -> { Spree::Hub::OrderSerializer.push_it self }
This extension provides your store with a generic endpoint to receive any webhook called
from the hub. The format for all of those is: http://mystore.com/hub/<WEBHOOK>
So for the add_product webhook, the endpoint url is http://mystore.com/hub/add_product
You need to implement the webhook handler yourself, since no store is a like.
The convention with this extension is that we dynamicly initialize a handler based on the webhook.
So with the add_product
sample, we will initialize Spree::Hub::Handler::AddProductHandler
and call process
Make sure you inherit your handler from Spree::Hub::Handler::Base
For some sample handlers (add_product and add_order) see this gists
Todo: extend the docs here!
Copyright (c) 2014 Spree Commerce, Inc. and other contributors, released under the New BSD License