-
-
Save vitorio/0302d02b3af0dd6ed609 to your computer and use it in GitHub Desktop.
One-time check for Microsoft Store stock
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
local sku = '309986300' | |
local zipcode = '10001' | |
local response = http.request { | |
url = 'https://rtgliveservices.cloudapp.net/Location/LocationService.svc/NearestSites?zipcode=' .. zipcode .. '&maxRadius=100' | |
} | |
local data = json.parse(response.content) | |
local sites = {} | |
for key1, value1 in pairs(data.result) do | |
table.insert(sites, value1.SiteId) | |
end | |
local query = '' | |
for i = 1, # sites do | |
if i > 1 then | |
query = query .. '+OR+' | |
end | |
query = query .. 'SiteId+eq+' .. sites[i] | |
end | |
local response = http.request { | |
url = 'http://rtgliveservices.cloudapp.net/Location/LocationService.svc/sites?filter=' .. query | |
} | |
local data = json.parse(response.content) | |
local stores = {} | |
for key1, value1 in pairs(data.result) do | |
table.insert(stores, value1) | |
end | |
local response = http.request { | |
url = 'http://rtgcatalogservices.cloudapp.net/Catalog.svc/StoreInventory?$format=json&$filter=ProductID+eq+' .. sku | |
} | |
local data = json.parse(response.content) | |
local responses = '' | |
for key1, value1 in pairs(data.value) do | |
if value1.InventoryLevel == 'IN_STOCK' then | |
for i = 1, # stores do | |
if stores[i].StoreNumber == value1.StoreID:gsub('W', '0') then | |
responses = responses .. 'SKU ' .. sku .. ' is now in stock at ' .. stores[i].Address .. ' in ' .. stores[i].Name .. '.\n\n' | |
end | |
end | |
end | |
end | |
return responses |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment