-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
playstation.ts
53 lines (51 loc) 路 1.33 KB
/
playstation.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {Store} from './store';
import fetch from 'node-fetch';
export const PlayStation: Store = {
labels: {
inStock: {
container: '.productHero-info .button-placeholder',
text: ['Add']
}
},
links: [
{
brand: 'test:brand',
itemNumber: '3005715',
model: 'test:model',
series: 'test:series',
url:
'https://direct.playstation.com/en-us/accessories/accessory/dualsense-wireless-controller.3005715'
},
{
brand: 'sony',
itemNumber: '3005816',
model: 'ps5 console',
series: 'sonyps5c',
url:
'https://direct.playstation.com/en-us/consoles/console/playstation5-console.3005816'
},
{
brand: 'sony',
itemNumber: '3005817',
model: 'ps5 digital',
series: 'sonyps5de',
url:
'https://direct.playstation.com/en-us/consoles/console/playstation5-digital-edition-console.3005817'
}
],
name: 'playstation',
realTimeInventoryLookup: async (itemNumber: string) => {
const request_url =
'https://api.direct.playstation.com/commercewebservices/ps-direct-us/products/productList?fields=BASIC&productCodes=' +
itemNumber;
const response = await fetch(request_url);
const response_json = await response.json();
if (
response_json.products[0].stock.stockLevelStatus !== 'outOfStock' &&
response_json.products[0].maxOrderQuantity >= 0
) {
return true;
}
return false;
}
};