Repository is archived
No commit activity in last 3 years
No release in over 3 years
Ruby wrapper for eBay Enterprise Affiliate Network API (formerly PepperJam Exchange API). See http://help.pepperjamnetwork.com/api for details.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 2.3.6, ~> 2.3
>= 4.3.2, ~> 4.3
~> 0.13
>= 1.8.1, ~> 1.8
 Project Readme

eBay Enterprise Affiliate Network API

Gem Version Build Status

Ruby wrapper for eBay Enterprise Affiliate Network API (formerly PepperJam Exchange API). Only Publisher API is supported at this moment. If you need Advertiser API or Partner API, feel free to contribute.

For questions or bugs please create an issue.

Installation

Add this line to your application's Gemfile:

gem 'ebay_enterprise_affiliate_network'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ebay_enterprise_affiliate_network

Requirements

Ruby 1.9 or above.

Usage

The gem is designed to support all existing and future Publisher API resources.

To start using the gem, you need to set up the api key first. If you use Ruby on Rails, the API key can be set in a configuration file (i.e. app/config/initializers/ebay_enterprise_affiliate_network.rb), otherwise just set it in your script. API Key can be found at http://www.pepperjamnetwork.com/affiliate/api/.

require "ebay_enterprise_affiliate_network" # no need for RoR
EBayEnterpriseAffiliateNetwork.api_key = ENV["EEAN_API_KEY"]

Examples

publisher = EBayEnterpriseAffiliateNetwork::Publisher.new
response = publisher.get("advertiser/category")
response.data.each do |category|
  puts "#{category.name} (ID #{category.id})"
end

# Retrieve the actual request URL sent to the API
puts response.request.uri.to_s

Get the list of advertisers that you have a joined relationship with. The second argument of get method accepts a Hash of parameters. See the API documentation for a list of parameters for each API resource. Note that the API resource used must match the ones available in documentation, except the publisher/ prefix that needs to be removed.

publisher = EBayEnterpriseAffiliateNetwork::Publisher.new
response = publisher.get("advertiser", status: :joined)
# Return the number of total records
response.meta.pagination.total_results
# Return the number of pages
response.meta.pagination.total_pages

response.data.each do |advertiser|
  # Do something
end

If there are multiple pages (each page has a maximum of 500 records, value that cannot be changed), you can retrieve all pages by using the all method, as follows:

response.all.each do |advertiser|
  # Do something
end

When using the all method, response object is updated with the data returned by the last API request (last page). response.all returns the data array.

Filter Target products by canon camera keywords.

params = {
  programIds: 6759, # Target ID
  keywords: "canon camera"
}
publisher = EBayEnterpriseAffiliateNetwork::Publisher.new
response = publisher.get("creative/product", params)
response.data.each do |product|
  puts "<a href=\"#{product.buy_url}\" title=\"#{product.name}\" target=\"_blank\">#{product.name}</a>"
end

Retrieve all transactions in the last day

require "date"
# Note that the API uses ET as time zone, although is not specified anywhere
yesterday = (Date.today - 1).to_s
today = Date.today.to_s
params = {
  startDate: yesterday,
  endDate: today,
  website: 12345 # replace with your website id
}
publisher = EBayEnterpriseAffiliateNetwork::Publisher.new
response = publisher.get("report/transaction-details", params)
response.data.each do |transaction|
  # Generate report
end

Website ID can be retrieved from http://www.pepperjamnetwork.com/affiliate.

Extra Configuration

  • EBayEnterpriseAffiliateNetwork.api_base_url - default value is http://api.pepperjamnetwork.com
  • EBayEnterpriseAffiliateNetwork.api_version - default value is 20120402
  • EBayEnterpriseAffiliateNetwork.api_timeout - the timeout set when initiating requests to eBay Enterprise Affiliate Network API (default value is 30 seconds)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

MIT