Skip to content

Ruby gem implementation of the HasOffers API for affiliate advertising.

License

Notifications You must be signed in to change notification settings

sportnginlegacy/hasoffers

Repository files navigation

HasOffers

TravisCI

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

⚠️ No longer suported ⚠️

This repository is no longer supported by SportNgin.

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

This repository is no longer actively supported. We recommend forking for continuing work.

About

Ruby gem implementation of the HasOffers API for affiliate advertising.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages