Git Product home page Git Product logo

hasoffers's Introduction

HasOffers

This gem hooks into the HasOffers API as documented here: www.hasoffers.com/wiki/Category:API

Install

gem install hasoffers

Usage

Add a has_offers.yml file to your RAILS_ROOT/config/ directory following the format outlined in the gems config/has_offers.yml file and change the credentials accordingly.

Example usage: (more examples in tests)

response = HasOffers::Offer.create('name' => 'Test',
                                   'description' => 'Test',
                                   'advertiser_id' => '1',
                                   'offer_url' => 'test',
                                   'preview_url' => 'test',
                                   'protocol' => 'https',
                                   'status' => 'active',
                                   'expiration_date' => (Date.today + 30).to_s)

When running in development mode, by default live api calls are not made. Dummy responses are returned from the DummyResponse class. Set the HAS_OFFERS_LIVE environment variable to “1” to make live api calls when in development mode like so:

Rails 2.x: env HAS_OFFERS_LIVE=1 script/server Rails 3.x: env HAS_OFFERS_LIVE=1 rails server

If you always want live api calls in development mode then you can add this line within the config.after_initialize block of your development.rb file:

config.after_initialize do

HasOffers::Base.api_mode = :live

end

Tests

The tests can be ran in two modes:

Test mode

  • rake test

Does not make live API calls. Dummy responses are returned by the DummyResponse class which is also used in development mode to avoid live API calls.

Live mode

  • env HAS_OFFERS_LIVE=1 rake test

Makes live api calls. Uses the HasOffer credentials in config/has_offers.yml which by default is set to the demo account credentials. HasOffers does not supply a test gateway so be careful to not run these tests against your live HasOffers account.

Contributing

The HasOffers API is huge and this gem implements only a portion of what is available with their API. With this framework in place it should be easy to extend the gem for API calls that are not yet supported. Please send contributions as git patches to [email protected], or alternatively create a fork and send a git pull request via github.

hasoffers's People

Contributors

lukeludwig avatar jphenow avatar zhengjia avatar

Watchers

Oleksii 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.