Giter VIP home page Giter VIP logo

peanut_labs's Introduction

Build Status Gem Version

PeanutLabs

This is a helper library for PeanutLabs.com integration.

Currently features include:

  • Building iframe for survey wall
  • Building DirectLinks
  • Whitelisting routes in rails

Documentation is here: http://peanut-labs.github.io/publisher-doc/index.html

Installation

Add this line to your application's Gemfile:

gem 'peanut_labs'

And then execute:

$ bundle

Or install it yourself as:

$ gem install peanut_labs

Usage

You need to provide you app_id and and app_key. Perfect place to do that in rails app is config/initialize/peanutlabs.rb file

PeanutLabs::Credentials.id = <YOUR APP ID>
PeanutLabs::Credentials.key = <YOUR KEY>

Whitelist

You would need callback in your app to receive response from peanutlabs. To do that securely, you need to whitelist your route in rails routes.rb file, like this:

require 'peanut_labs/whitelist'
post "callback/peanutlabs" => "callback#peanutlabs", constraints: PeanutLabs::Whitelist

Whitelist was taken from official documentation: http://peanut-labs.github.io/publisher-doc/index.html#ipwhitelist

Iframe

PeanutLabs::Builder::IframeUrl.call(id: user.pid)

Possible attributes

  • id: required, public user ID (highly recommended not to expose descending IDs in here)
  • dob: not required, classes accepted - Date, DateTime, Time or formatted "MM-DD-YYYY" string
  • sex: not required, 1 for male, 2 for female

Direct Links

PeanutLabs::Builder::DirectLink.call(user.pid, attributes = {})

Possible attributes (not required)

  • payload: a hash with user data attributes for encryption
  • sub_id: a secure session id. Will be returned during postback notification
  • zl: survey language (for some reason, PN translates only interface but not questions)

Development

Be a good lad and write specs, we love code we can rely on.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/saberespoder/peanut_labs.

License

The gem is available as open source under the terms of the MIT License.

peanut_labs's People

Contributors

query-string avatar

Watchers

 avatar James Cloos avatar  avatar

peanut_labs's Issues

Rip off never used classes

Such classes as Builder::Profile are only confusing since only Iframe and DirectLinks builders mostly used

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.