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

snl-peddler

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snl-peddler

  • 0.1.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= Peddler

Peddler is a Ruby wrapper to the Amazon Inventory management API.

== Example usage

Fire off a client:

client = Peddler::Client.new( :username => "foo@bar.com", :password => "secret", :region => "us")

Create an inventory file:

batch = client.new_inventory_batch item = client.new_inventory_item( :product_id => "1234567890", :price => 100.00, :sku => "SKU-123", :quantity => 10) batch << item ...

Repeat ad infinitum and upload:

batch.upload

The batch now should have an upload ID. Go ahead and check the error log:

upload_log = client.new_report( :upload, :id => batch.id) upload_log.body => "Feed Processing Summary:\n\tNumber of records processed\t\t1\n\tNumber of records successful\t\t1\n\n"

You're done listing and are wondering if you have any new orders:

orders_report = client.new_report :order orders = client.detab(orders_report.body) p orders.size => 1500 p orders[0].item_name => "A Thousand Plateaus: Capitalism and Schizophrenia (Paperback) by Gilles Deleuze"

Now that you have diligently processed the orders, post back the results to Amazon:

feed = client.new_order_fulfillment_feed fulfilled_order = client.new_fulfilled_order( :order_id => "123-1234567-1234567", :order_date => "2009-08-01", :carrier_code => "USPS", :tracking_number => "0308 0330 0000 0000 0000") feed << fulfilled_order

Again, repeat until done and upload:

feed.upload

Curious to see the processing report?

p feed.status => "SUBMITTED"

Refresh until you get:

p feed.status! => "DONE"

Finally, check the report:

p feed.download.to_s => ...

Sadly, you also have an order you can't fulfill. No problem. The workflow is similar:

feed = client.new_order_cancellation_feed cancelled_order = client.new_cancelled_order( :order_id => "123-1234567-1234567", :cancellation_reason_code => "NoInventory", :amazon_order_item_code => "12341234567890") feed << cancelled_order feed.upload sleep(60) feed.status! => "DONE"
p feed.download.to_s => ...

Need to post a partial refund? You'll have to revert to the older batch refund API method:

refunds = client.new_refund_batch refund = client.new_refund( :order_id => "123-1234567-1234567", :payments_transaction_id => "12341234567890", :refund_amount => 1.00, :reason => "GeneralAdjustment", :message => "With our apologies.") refunds << refund refunds.upload

Great sales. For a change, let's download something different from Amazon. Here's a preorder report:

preorder_report = client.new_report( :preorder, :product_line => "Books", :frequency => 2) preorders = client.detab(preorder_report.body) p preorders.size => 2000 p preorders[0].asin => "1234567890" p preorders[0].average_asking_price => "100"

Run rdoc and check the source for more detailed info.

Copyright © 2009 Hakan Senol Ensari, released under the MIT license

FAQs

Package last updated on 10 Aug 2014

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