Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commission_junction

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commission_junction

  • 2.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

commission_junction

Ruby wrapper for the Commission Junction web services APIs (REST)

See https://cjcommunity.force.com/s/article/4777058.

Gem Version

Installation

Add this line to your application's Gemfile:

gem 'commission_junction'

And then execute

bundle

Or install it yourself as:

gem install commission_junction

Example

require 'commission_junction'

# See https://api.cj.com/sign_up.cj.
DEVELOPER_KEY = '????????'.freeze

# See cj.com > Account > Websites.
WEBSITE_ID = '????????'.freeze

cj = CommissionJunction.new(DEVELOPER_KEY, WEBSITE_ID)

# See https://cjcommunity.force.com/s/article/4777185
# for the list of request and response parameters.
cj.product_search('keywords' => '+blue +jeans',
                  'advertiser-ids' => 'joined',
                  'serviceable-area' => 'us',
                  'currency' => 'usd',
                  'records-per-page' => '5').each do |product|
  puts product.name
  puts product.price
  puts product.image_url
  puts ''
end

# See https://cjcommunity.force.com/s/article/4777195
# for the list of request and response parameters.
cj.advertiser_lookup('keywords' => '+used +books',
                     'advertiser-ids' => 'joined',
                     'records-per-page' => '5').each do |advertiser|
  puts advertiser.advertiser_name
  puts advertiser.network_rank
  puts advertiser.program_url
  puts ''
end

# See https://cjcommunity.force.com/s/article/4777180
# for the list of request and response parameters.
cj.link_search('keywords' => '+used +books',
               'advertiser-ids' => 'joined',
               'records-per-page' => '5').each do |link|
  puts link.link_id
  puts link.link_name
  puts link.link_code_html
  puts link.sale_commission
  puts ''
end

# See https://cjcommunity.force.com/s/article/4777190
# for the list of request and response parameters.
puts cj.categories

# See https://cjcommunity.force.com/s/article/4777175
# for the list of request and response parameters.
ids = []

cj.commissions.each do |commission|
  ids << commission.original_action_id
  puts commission.action_type
  puts commission.aid
  puts commission.commission_id
  puts commission.event_date
  puts commission.advertiser_name
  puts commission.commission_amount
  puts commission.sid
  puts ''
end

# Each commission comes from the sale of one or more items.
# Commissions and their items are linked by original_action_id.
cj.item_detail(ids[0, 50]).each do |item_detail|
  puts item_detail['original_action_id']

  items = item_detail['item']
  # If there is exactly one item, put it in an array.
  items = [items] if items.is_a?(Hash)

  items.each do |item|
    puts item['sku']
    puts item['quantity']
    puts item['posting_date']
    puts item['commission_id']
    puts item['sale_amount']
    puts item['discount']
    puts item['publisher_commission']
  end if items
end

Dependencies

  • httparty
  • ox

Contributing

  • Feel free to file a bug report or enhancement request, even if you don't have time to submit a patch.
  • Please try to include a test for any patch you submit. If you don't include a test, I'll have to write one, and it'll take longer to get your code in.
  • Remember to send me a pull request.

Authors

Copyright (c) 2012 Albert Vernon. See LICENSE for details.

FAQs

Package last updated on 12 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc