Skip to content

Diamond Comics is the primary comic book distributor in North America. This library helps retailer with a Diamond Comics account interact with the Diamond website.

Notifications You must be signed in to change notification settings

TJamesCorcoran/diamond_remote

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DiamondRemote

Diamond Comics is the primary comic book distributor in North America.

This Ruby / Rails library helps a retailer with a Diamond Comics account interact with the Diamond website.

The API lets you:

  • download datafiles of upcoming comics & current Diamond inventory

  • download ISBNs, UPCs, cover images

  • place reorders and monthly initial orders.

Installation

  1. add this to your Gemfile

    gem "diamond_remote", :git =>"http://github.com/TJamesCorcoran/diamond_remote"
    
  2. at the command line type

    bundle install
    
  3. get a username, password, and customer number from Diamond Comics.

  4. Using credentials from previous step, add this to your config/application.rb

    DiamondRemote.configure do |config|
      config.username                      = 'tru<x>'   
      config.password                      = '<y>'
      config.custnumber                    = '<x>'
      config.firm_name_at_diamond          = /FIRM NAME AS REGEXP/
      config.download_dir                  = "#{Rails.root}/lib/datafiles/"
    end
    
  5. That’s it. You can now begin interacting with the Diamond website programatically.

Use: Download Data Files

Diamond supplied three data files.

  • preview - updated once per month; lists items available next month

  • master - updated once per month; contains same items as previews, but w different fields

  • truall - updated nightly; shows everything that is orderable or reorderable

Here’s how to download them:

# download a "master" and a "preview" datafile from Diamond
#
DiamondRemote.get_master(  "2015", "02")
=> #<File:/home/xxx/src/yyy/lib/datafiles/lib/datafiles/201502/master.csv> 

DiamondRemote.get_previews("2015", "02")
=> #<File:/home/xxx/src/yyy/lib/datafiles/lib/datafiles/201502/previews.csv> 

# or get both at once
#
DiamondRemote.get_both("2015", "02")
=> [ #<File...> , #<File..> ]

# or get both for current month
DiamondRemote.get_current()
=> [ #<File...> , #<File..> ]

# get and parse truall file
DiamondRemote.get_truall()
=>    [  {:code       =>"APR962656",
        :title      =>"CRIME SUSPENSTORIES #17",
        :price      =>"0000002.5000",
        :type       =>"1",
        :date       =>"09/13/96",
        :base_price =>"0000002.5000 ",
        :vendor     =>"WILLIAM M GAINES, VIA GEMSTONE ",
        :discount   =>"E"},
       {:code       =>"STAR06965",
        :title      =>"LOVE & ROCKETS SC VOL 15 HERNANDEZ SATYRICON (MR) (O/A)",
        :price      =>"0000018.9500 ",
        :type       =>"3",
        :date       =>"09/30/97",
        :base_price =>"0000018.9500 ",
        :vendor     =>"FANTAGRAPHICS BOOKS",
        :discount   =>"E"},
     ...
     ]

# download your invoices
#
DiamondRemote.invoices_download_all
 => { <Date-1> => <invoice-as-text>,
    <Date-2> => <invoice-as-text>,
    <Date-3> => <invoice-as-text>
    ...
   }

Use: Get Release Dates, ISBNs, UPCs, and Cover Images

# find Diamond's release date for items, specifying them by their itemcodes
#
DiamondRemote.get_diamond_release_dates(["JAN152628", "JAN152627"] )
=> {"JAN152628"=>Wed, 04 Mar 2015, 
   "JAN152627"=>Wed, 04 Mar 2015} 

# get an image 
#
DiamondRemote.get_diamond_image("JAN152628", "/tmp/JAN152628.jpg") 
=> "/tmp/JAN152628.jpg" 

# get ISBNs for graphic novels
#    (works via block)
#
DiamondRemote.get_GN_ISBNs(["AUG080052" , "JAN152628" ]) do |code, isbn| 
  puts "#{code} #{isbn}" 
end

# get UPCs for a comic books
#    (works via block)
#
DiamondRemote.get_IC_UPCS(["JAN152621", "JAN151887"] ) do |code, upc| 
  puts "#{code} #{upc}" 
end

Use: Place Initial Orders and Reorders

# find deadline for initial order
#
DiamondRemote.get_order_deadline()
=> ["FEB15", Mon, 02 Mar 2015] 

# submit an initial order
#
DiamondRemote.submit_initial!( { "JAN152628" => 1, "JAN152627" => 10 } )
=> true

# submit a reorder
#
DiamondRemote.submit_reorder!( { "JAN152628" => 1, "JAN152627" => 10 } )
=> true

Support

If you have features you need, or want other help building or maintaining your comics-based ecommerce site, please contact me a [email protected]

About

Diamond Comics is the primary comic book distributor in North America. This library helps retailer with a Diamond Comics account interact with the Diamond website.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages