mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 01:47:39 +00:00
feat(store): add PlayStation store (#806)
This commit is contained in:
@@ -184,6 +184,7 @@ environment variables are **optional**._
|
||||
| Office Depot | `officedepot`|
|
||||
| Overclockers (UK) | `overclockers`|
|
||||
| PCComponentes (ES) | `pccomponentes`|
|
||||
| PlayStation | `playstation`|
|
||||
| PNY | `pny`|
|
||||
| Proshop (DE) | `proshop-de`|
|
||||
| Proshop (DK) | `proshop-dk`|
|
||||
|
||||
@@ -48,6 +48,7 @@ import {NvidiaApi} from './nvidia-api';
|
||||
import {OfficeDepot} from './officedepot';
|
||||
import {Overclockers} from './overclockers';
|
||||
import {PCComponentes} from './pccomponentes';
|
||||
import {PlayStation} from './playstation';
|
||||
import {Pny} from './pny';
|
||||
import {ProshopDE} from './proshop-de';
|
||||
import {ProshopDK} from './proshop-dk';
|
||||
@@ -111,6 +112,7 @@ export const storeList = new Map([
|
||||
[OfficeDepot.name, OfficeDepot],
|
||||
[Overclockers.name, Overclockers],
|
||||
[PCComponentes.name, PCComponentes],
|
||||
[PlayStation.name, PlayStation],
|
||||
[Pny.name, Pny],
|
||||
[ProshopDE.name, ProshopDE],
|
||||
[ProshopDK.name, ProshopDK],
|
||||
|
||||
@@ -0,0 +1,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;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user