Created
November 20, 2015 21:17
-
-
Save atomgiant/0025a38e96229e85f270 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Takes a product id, and a map of variant ids and quantities | |
def update_inventory(id, vid_quantities) | |
variants = vid_quantities.map do |vid, qty| | |
{ "id" => vid, "inventory_quantity" => qty } | |
end | |
data = { | |
"product" => { | |
"variants" => variants | |
} | |
} | |
request(:put, "products/#{id}.json", body: data.to_json) | |
end | |
update_inventory(1234567, {2222222 => 100, 3333333 => 200}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment