Created
July 29, 2021 01:19
-
-
Save abossard/965040c1791dd76ac7389184d5efc9a1 to your computer and use it in GitHub Desktop.
Find PS5 and XSX "secret" stock in melectronic stores
This file contains hidden or 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
{ | |
"stores": [ | |
{ | |
"storeId": "0045140", | |
"marketId": "0045150_mec", | |
"kst": "0045150", | |
"pickmupServiceTypePresent": false, | |
"name": "melectronics - Carouge - MParc La Praille", | |
"text": "<p>Auf über 1200m2 finden Sie bei uns ein ausgewähltes Sortiment an neuester Unterhaltungs- und Heimelektronik mit attraktiven Top-Marken zu gewohnt günstigen Preisen.</p>\n\n<p> </p>\n\n<p>Lassen Sie sich von unseren fachkundigen Mitarbeiterinnen und Mitarbeitern unsere aktuellen Angebote zeigen und kompetent beraten. Profitieren Sie auch von unseren zahlreichen Service- und Dienstleistungen wie die kostenlose Heimlieferung oder die Installation und Inbetriebnahme Ihres Geräts.</p>\n\n<p> </p>\n\n<p>Sie erreichen uns bequem mit dem öffentlichen Verkehr der Linien 11, 12, 18, 21, 22, 41, 42, 44, 45 oder benutzen Sie unsere zahlreichen Parkmöglichkeiten.</p>\n\n<p> </p>\n\n<p> </p>\n\n<p>Wir freuen uns auf Ihren Besuch!</p>\n\n<p>Ihr melectronics Team</p>\n", | |
"storeType": "fm", | |
"phone": "058 573 42 00", | |
"location": { | |
"address": "Avenue Vibert 32", | |
"zip": "1227", | |
"city": "Carouge GE", | |
"latitude": 46.1847993, | |
"longitude": 6.1339501, | |
"country": "CH" | |
}, | |
"distance": 208.6499506017, | |
"stock": { | |
"stockStatus": 2, | |
"inventory": 0 | |
}, | |
"imageUrls": [ | |
"//image.migros.ch/filialen/{stack}/624a674e345c7f39f2333af1874ef32d61da20b9/melectronics-carouge-mparc-la-praille-image.jpg" | |
], | |
"logoUrl": "https://image.migros.ch/filialen/{stack}/faffada7c8c6c44e7fe75da440d501c6d08a851c/mec-de-logo.png", | |
"marketName": "melectronics", | |
"url": "/de/cp/store/0045150/melectronics-carouge-mparc-la-praille", | |
"cooperativeName": "Genf", | |
"isPickMUpBox": false, | |
"ownSubsidiary": true, | |
"hint": "" | |
} | |
], | |
"latitude": 47.3830192, | |
"longitude": 8.2430405 | |
} |
This file contains hidden or 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
open FSharp.Data | |
type Product = { id: string; name: string } | |
let products = | |
[ { id = "785446600000" | |
name = "XBox Series X" } | |
{ id = "785445800000" | |
name = "PlayStation 5 Digital Edition" } | |
{ id = "785445700000" | |
name = "PlayStation 5" } | |
] | |
let location = "*002%20Zurich" | |
type MelectronicsStoreList = JsonProvider<"./example.json"> | |
type ProductStores = { product: Product; url: string } | |
type ProductStores2 = { product: Product; url: string; data: MelectronicsStoreList.Root} | |
let getUrlForProductList location productId = | |
$"https://www.melectronics.ch/jsapi/v1/de/stores/inventory/{productId}?location={location}&availabilityStock=0,1" | |
let results = | |
products | |
|> List.map | |
(fun product -> | |
{ product = product | |
url = product.id |> getUrlForProductList location }) | |
|> List.map | |
(fun product -> { | |
product = product.product | |
url = product.url | |
data = product.url |> MelectronicsStoreList.Load | |
}) | |
let formatStores (stores: MelectronicsStoreList.Store []): string = | |
stores |> Array.map (fun store -> $"{store.Name} ({store.Phone}) ") |> Array.fold (+) "" | |
let filterResults = results | |
|> List.where (fun result -> result.data.Stores.Length > 0) | |
|> List.map (fun result -> $"\n{result.product.name} is available in {formatStores result.data.Stores}") | |
// Define a function to construct a message to print | |
[<EntryPoint>] | |
let main argv = | |
printfn $"Available now: %A{filterResults}" | |
0 // return an integer exit code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment