Skip to content

Commit

Permalink
feat(store): add PlayStation store (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Hinton committed Nov 15, 2020
1 parent b21b244 commit 7c28c7f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -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`|
Expand Down
2 changes: 2 additions & 0 deletions src/store/model/index.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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],
Expand Down
53 changes: 53 additions & 0 deletions src/store/model/playstation.ts
@@ -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;
}
};

0 comments on commit 7c28c7f

Please sign in to comment.