Giter Club home page Giter Club logo

commission_junction's Introduction

Archived project. No maintenance.

This project is not maintained anymore and is archived. Feel free to fork and make your own changes if needed.

Thanks to everyone for your valuable feedback and contributions.

commission_junction

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

See https://developers.cj.com/docs/rest-apis/overview.

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

Authors

Copyright

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

commission_junction's People

Contributors

aevernon avatar jsboulanger avatar k-s-a avatar samsaradog avatar vemv 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.