Coder Social home page Coder Social logo

iloveitaly / hub_gem Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spree/hub_gem

0.0 3.0 0.0 460 KB

Helper gem to help communication between a Spree Commerce storefront and hub

License: BSD 3-Clause "New" or "Revised" License

Ruby 100.00%

hub_gem's Introduction

spree_hub

Installation

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

Testing

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'

Sample Order Decorator

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 }

Consuming webhooks from the hub

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

hub_gem's People

Contributors

peterberkenbosch avatar huoxito avatar

Watchers

Michael Bianco avatar James Cloos avatar  avatar

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.