Viglink
This gem is a wrapper for the Viglink Catalog API. This gem contains module methods for each API endpoint, as well as an additional subset for the CUID revenue API.
Installation
Command line installation:
gem install viglink-api
Or add this line to your application's Gemfile:
gem 'viglink-api'
And then execute bundler:
bundle
Usage
Irb/Console
To use in irb or a console, simply require the file and create a new client
require 'viglink_api'
viglink = ViglinkApi::Client.new({:api_key => ENV['VIGLINK_API_KEY']})Rails
Include the viglink-api gem in your Gemfile and bundle. The module can be configured by creating a config file:
config/initializers/viglink.rb
ViglinkApi.configure do |config|
config.api_key = "your_api_key"
endAnd then initialize a client with the following:
viglink = ViglinkApi::Client.newPlease see below for more configuration options.
Search Methods
Please refer to the Viglink Catalog API documentation for details on additional fields that can be included. Each method can accept a hash of values to pass through to the search. Key is included by default.
find_productsfind_merchantsfind_merchant_typesfind_dealsfind_deal_typesfind_countries
Configuration Options
-
api_urlsets the API base url. Default: http://catalog.viglink.com -
api_keyshould be set to your campaign API key. Default: nil -
api_keycan be set to your campaign API secret key. Default: nil -
api_full_responseDetermines if the searches return the full response hashes or only the segment of the response related to the request. Default: true -
api_cuid_urlsets the CUID API base url. Default: https://www.viglink.com/service/v1/cuidRevenue
CUID Payment API
Please refer to the Viglink CUID API documentation (the section on "Advanced Revenue Tracking") for additional information.
Usage
The defaults for this segment of the API default to the general ViglinkApi configuration
viglink = ViglinkApi::Purchases.newOr for a one-off call independent from the ViglinkApi configuration (please see below for more configuration options):
viglink = ViglinkApi::Purchases.new({:api_secret => "your_secret_key", :period => "week"})Methods
-
find_purchasesperforms a search and accepts an options hash with the following keys:-
last_datesets the start date for search. Format: YYYY/MM/DD ("%Y/%m/%d"). Default: 1 day ago. -
perioddetermines the search period. Options: day, week, month. Default: day
-
Options
-
api_secretshould be set to your Viglink API secret key. Default: nil -
api_cuid_url= options[:api_cuid_url] || ViglinkApi.api_cuid_url -
last_datesets the start date for search. Format: YYYY/MM/DD ("%Y/%m/%d"). Default: 1 day ago. -
perioddetermines the search period. Options: day, week, month. Default: day
Contributing
Contributions welcome!
- We need more tests, and the existing ones need updating
- More documentation and code commenting
- Debugging and exception handling
- Features!
In traditional GitHub style:
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request