Giter Club home page Giter Club logo

hasoffersv3's Introduction

Overview

Build status

Synopsis

This gem provides a wrapper around HasOffers API in version 3, HasOffers APIv3 Documentation.

Compatibility

Supported ruby versions:

  • 1.9.3
  • 2.0
  • 2.1
  • 2.2

Installation

gem install hasoffersv3

Usage

First, check if the method you want to call is already defined in hasoffersv3/lib/hasoffersv3/*. If not, you will need to add the method yourself (either just use your fork or submit a PR with your changes).

Next, create an initializer in your project in config/intializers and configure your API credentials like so:

HasOffersV3.configure do |config|
  config.api_key      = ENV['YOUR_HAS_OFFERS_API_KEY']
  config.network_id   = ENV['YOUR_HAS_OFFERS_NETWORK_ID']
  config.read_timeout = 10
end

You can now use the defined methods, following this pattern:

HasOffersV3::ControllerName.snake_case_method_name

If HasOffers method does not take any parameters, then API also doesn't take them, otherwise it should be always a hash.

Naming is the same as in HasOffers documentation, also if it requires attributes then API will raise an exception if it's missing.

Examples:

HasOffersV3::Affiliate.update_payment_method_wire({ affiliate_id: '877', data: {} })

or when working with forms:

HasOffersV3::Advertiser.signup({
  account: {
    company: params[:company_name],
    country: params[:company_country],
    address1: 'Change me 123',
    zipcode: '123123'
  },
  user: {
    first_name: params[:user_name],
    email: params[:user_email],
    password: params[:user_password],
    password_confirmation: params[:user_password_confirmation]
  },
  return_object: 1
})

Testing

If RAILS_ENV or RACK_ENV is set to test, or there's a TEST environment variable, it will require the HasOffersV3::Testing module and enable testing mode. In testing mode all requests will return stubbed successful response with empty data set.

When you need to disable testing mode:

HasOffersV3::Testing.disable!

When you want to provide custom stub:

HasOffersV3::Testing.stub_request status_code, body

hasoffersv3's People

Contributors

miry avatar troessner avatar mseifert avatar psychocandy avatar kostyantyn avatar driv3r avatar shekhardokania avatar demitryt avatar tiagotex avatar christhomson avatar

Watchers

Dmitry Halai avatar James Cloos 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.