Coder Social home page Coder Social logo

mollom_rest_api's Introduction

Build Status Coverage Status

Mollom Rest API

mollom_rest_api is a ruby wrapper, using oauth authentication, for the Mollom Rest API.

Tested against:

  • Ruby 1.9.3
  • Ruby 2.1.2

Installation

Add to your Gemfile:

gem 'mollom_rest_api'

or install from Rubygems:

gem install mollom_rest_api

Usage

Before using the gem, you must first configure it as such:

MollomRestApi.url = 'http://rest.mollom.com' # Do not include the API version number
MollomRestApi.public_key = 'my_public_key'
MollomRestApi.private_key = 'my_private_key'
MollomRestApi.oauth_options = {proxy: 'http://proxy.com:8888'} # some additional oauth options

You can get your public key and private key using Mollom's site manager, after signing in.

Calling endpoints

The gem implementation replicates the Mollom's API Documentation as much as possible.

Example of API call

Here is an example of how to verify a captcha using the gem.

As per Mollom's Documentation on verifying a captcha:

Syntax: POST http://rest.mollom.com/v1/captcha
  • Path parameters
    • captchaId: The ID of the CAPTCHA resource.
  • Request parameters
    • solution:
      • The answer provided by the author.
    • authorName: (optional)
      • The name of the content author.
    • authorUrl: (optional)
      • The homepage/website URL of the content author.
    • authorMail: (optional)
      • The e-mail address of the content author.
    • authorIp: (optional)
      • The IP address of the content author.
    • authorId: (optional)
      • The local user ID of the content author on the client site.
    • authorOpenid: (multiple, optional)
      • One or more Open IDs of the content author.
    • rateLimit: (optional, default = 15)
      • Seconds that must have passed by for the same author to post again.
    • honeypot: (optional)
      • Client-side honeypot value, if non-empty.

As such, captchaId and solution must both be specified for the endpoint call to succeed. All other parameters are optional, and can be passed to the call using a hash.

Using the gem, we call this endpoint using:

MollomRestApi::V1::Captcha.verify("captchaId", "solution", {authorName: "Bob", ...})

or using the alternative syntax:

MollomRestApi::V1::verify_captcha("captchaId", "solution", {authorName: "Bob", ...})

Running Tests

bundle exec rspec spec - Running specs (all web interactions are mocked with VCR cassettes)

Contributors

mollom_rest_api's People

Contributors

krystosterone avatar royjs avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

nicholaslemay

mollom_rest_api's Issues

Add clarification how the input and output is parsed and tested

When I look at https://github.com/Krystosterone/mollom_rest_api/blob/master/lib/mollom_rest_api/v1/captcha.rb, I have a hard time understanding what this class is supposed to return. I think a better pattern is to parse the output in the same class and have response objects that are interfaced so that it is clear what one can do with the response objects/data.

Can you clarify how you are working with this gem and if you are expecting mollom to not change it's responses or add values?

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.