mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 04:07:36 +00:00
feat(store): add microcenter store location config (#215)
Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
@@ -10,6 +10,7 @@ EMAIL_PASSWORD=""
|
|||||||
HEADLESS=""
|
HEADLESS=""
|
||||||
IN_STOCK_WAIT_TIME=""
|
IN_STOCK_WAIT_TIME=""
|
||||||
LOG_LEVEL=""
|
LOG_LEVEL=""
|
||||||
|
MICROCENTER_LOCATION=""
|
||||||
OPEN_BROWSER=""
|
OPEN_BROWSER=""
|
||||||
PAGE_TIMEOUT=""
|
PAGE_TIMEOUT=""
|
||||||
PHONE_NUMBER=""
|
PHONE_NUMBER=""
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ Here is a list of variables that you can use to customize your newly copied `.en
|
|||||||
| `HEADLESS` | Puppeteer to run headless or not | Debugging related, default: `true` |
|
| `HEADLESS` | Puppeteer to run headless or not | Debugging related, default: `true` |
|
||||||
| `IN_STOCK_WAIT_TIME` | Time to wait between requests to the same store if it has cards in stock | In seconds, default: `0` |
|
| `IN_STOCK_WAIT_TIME` | Time to wait between requests to the same store if it has cards in stock | In seconds, default: `0` |
|
||||||
| `LOG_LEVEL` | [Logging levels](https://github.com/winstonjs/winston#logging-levels) | Debugging related, default: `info` |
|
| `LOG_LEVEL` | [Logging levels](https://github.com/winstonjs/winston#logging-levels) | Debugging related, default: `info` |
|
||||||
|
| `MICROCENTER_LOCATION` | Specific MicroCenter location to search | Default : `web` |
|
||||||
| `OPEN_BROWSER` | Toggle for whether or not the browser should open when item is found | Default: `true` |
|
| `OPEN_BROWSER` | Toggle for whether or not the browser should open when item is found | Default: `true` |
|
||||||
| `PAGE_TIMEOUT` | Navigation Timeout in milliseconds | `0` for infinite, default: `30000` |
|
| `PAGE_TIMEOUT` | Navigation Timeout in milliseconds | `0` for infinite, default: `30000` |
|
||||||
| `PHONE_NUMBER` | 10 digit phone number | E.g.: `1234567890`, email configuration required |
|
| `PHONE_NUMBER` | 10 digit phone number | E.g.: `1234567890`, email configuration required |
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ const page = {
|
|||||||
|
|
||||||
const store = {
|
const store = {
|
||||||
country: envOrString(process.env.COUNTRY, 'usa'),
|
country: envOrString(process.env.COUNTRY, 'usa'),
|
||||||
|
microCenterLocation: envOrString(process.env.MICROCENTER_LOCATION, 'web'),
|
||||||
showOnlyBrands: envOrArray(process.env.SHOW_ONLY_BRANDS),
|
showOnlyBrands: envOrArray(process.env.SHOW_ONLY_BRANDS),
|
||||||
showOnlySeries: envOrArray(process.env.SHOW_ONLY_SERIES, ['3070', '3080', '3090']),
|
showOnlySeries: envOrArray(process.env.SHOW_ONLY_SERIES, ['3070', '3080', '3090']),
|
||||||
stores: envOrArray(process.env.STORES, ['nvidia'])
|
stores: envOrArray(process.env.STORES, ['nvidia'])
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export function sendNotification(link: Link, store: Store) {
|
|||||||
|
|
||||||
if (notifications.phone.number) {
|
if (notifications.phone.number) {
|
||||||
Logger.debug('↗ sending sms');
|
Logger.debug('↗ sending sms');
|
||||||
const carrier = notifications.phone.carrier.toLowerCase();
|
const carrier = notifications.phone.carrier;
|
||||||
if (carrier && notifications.phone.availableCarriers.has(carrier)) {
|
if (carrier && notifications.phone.availableCarriers.has(carrier)) {
|
||||||
sendSMS(link, store);
|
sendSMS(link, store);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export function sendSMS(link: Link, store: Store) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateAddress() {
|
function generateAddress() {
|
||||||
const carrier = phone.carrier.toLowerCase();
|
const carrier = phone.carrier;
|
||||||
|
|
||||||
if (carrier && phone.availableCarriers.has(carrier)) {
|
if (carrier && phone.availableCarriers.has(carrier)) {
|
||||||
return [phone.number, phone.availableCarriers.get(carrier)].join('@');
|
return [phone.number, phone.availableCarriers.get(carrier)].join('@');
|
||||||
|
|||||||
@@ -1,10 +1,48 @@
|
|||||||
|
import {Config} from '../../config';
|
||||||
import {Store} from './store';
|
import {Store} from './store';
|
||||||
|
|
||||||
|
const MicroCenterLocation = Config.store.microCenterLocation;
|
||||||
|
const microCenterLocationToId: Map<string, string> = new Map([
|
||||||
|
['web', '029'],
|
||||||
|
['brooklyn', '115'],
|
||||||
|
['brentwood', '095'],
|
||||||
|
['cambridge', '121'],
|
||||||
|
['chicago', '151'],
|
||||||
|
['columbus', '141'],
|
||||||
|
['dallas', '131'],
|
||||||
|
['devin', '181'],
|
||||||
|
['duluth', '065'],
|
||||||
|
['fairfax', '081'],
|
||||||
|
['flushing', '145'],
|
||||||
|
['houston', '155'],
|
||||||
|
['madison-heights', '055'],
|
||||||
|
['marietta', '041'],
|
||||||
|
['mayfiend-heights', '051'],
|
||||||
|
['north-jersey', '075'],
|
||||||
|
['overland-park', '191'],
|
||||||
|
['parkville', '125'],
|
||||||
|
['rockville', '085'],
|
||||||
|
['sharonville', '071'],
|
||||||
|
['st-davids', '061'],
|
||||||
|
['st-louis-park', '045'],
|
||||||
|
['tustin', '101'],
|
||||||
|
['westbury', '171'],
|
||||||
|
['westmont', '025'],
|
||||||
|
['yonkers', '105']
|
||||||
|
]);
|
||||||
|
|
||||||
|
let storeId: string;
|
||||||
|
if (microCenterLocationToId.get(MicroCenterLocation) === undefined) {
|
||||||
|
storeId = '029';
|
||||||
|
} else {
|
||||||
|
storeId = microCenterLocationToId.get(MicroCenterLocation)!;
|
||||||
|
}
|
||||||
|
|
||||||
export const MicroCenter: Store = {
|
export const MicroCenter: Store = {
|
||||||
labels: {
|
labels: {
|
||||||
inStock: {
|
inStock: {
|
||||||
container: '#cart-options',
|
container: '#cart-options',
|
||||||
text: ['(in stock)']
|
text: ['in stock']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
links: [
|
links: [
|
||||||
@@ -12,43 +50,43 @@ export const MicroCenter: Store = {
|
|||||||
brand: 'test:brand',
|
brand: 'test:brand',
|
||||||
model: 'test:model',
|
model: 'test:model',
|
||||||
series: 'test:series',
|
series: 'test:series',
|
||||||
url: 'https://www.microcenter.com/product/618433/evga-geforce-rtx-2060-ko-ultra-overclocked-dual-fan-6gb-gddr6-pcie-30-graphics-card'
|
url: `https://www.microcenter.com/product/618433/evga-geforce-rtx-2060-ko-ultra-overclocked-dual-fan-6gb-gddr6-pcie-30-graphics-card/?storeid=${storeId}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
brand: 'evga',
|
brand: 'evga',
|
||||||
model: 'xc3 ultra',
|
model: 'xc3 ultra',
|
||||||
series: '3080',
|
series: '3080',
|
||||||
url: 'https://www.microcenter.com/product/628344/evga-geforce-rtx-3080-xc3-ultra-gaming-triple-fan-10gb-gddr6x-pcie-40-graphics-card'
|
url: `https://www.microcenter.com/product/628344/evga-geforce-rtx-3080-xc3-ultra-gaming-triple-fan-10gb-gddr6x-pcie-40-graphics-card/?storeid=${storeId}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
brand: 'msi',
|
brand: 'msi',
|
||||||
model: 'ventus 3x',
|
model: 'ventus 3x',
|
||||||
series: '3080',
|
series: '3080',
|
||||||
url: 'https://www.microcenter.com/product/628331/msi-geforce-rtx-3080-ventus-3x-overclocked-triple-fan-10gb-gddr6x-pcie-40-graphics-card'
|
url: `https://www.microcenter.com/product/628331/msi-geforce-rtx-3080-ventus-3x-overclocked-triple-fan-10gb-gddr6x-pcie-40-graphics-card/?storeid=${storeId}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
brand: 'asus',
|
brand: 'asus',
|
||||||
model: 'tuf',
|
model: 'tuf',
|
||||||
series: '3080',
|
series: '3080',
|
||||||
url: 'https://www.microcenter.com/product/628303/asus-geforce-rtx-3080-tuf-gaming-triple-fan-10gb-gddr6x-pcie-40-graphics-card'
|
url: `https://www.microcenter.com/product/628303/asus-geforce-rtx-3080-tuf-gaming-triple-fan-10gb-gddr6x-pcie-40-graphics-card/?storeid=${storeId}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
brand: 'msi',
|
brand: 'msi',
|
||||||
model: 'gaming x trio',
|
model: 'gaming x trio',
|
||||||
series: '3080',
|
series: '3080',
|
||||||
url: 'https://www.microcenter.com/product/628330/msi-geforce-rtx-3080-gaming-x-trio-triple-fan-10gb-gddr6x-pcie-40-graphics-card'
|
url: `https://www.microcenter.com/product/628330/msi-geforce-rtx-3080-gaming-x-trio-triple-fan-10gb-gddr6x-pcie-40-graphics-card/?storeid=${storeId}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
brand: 'evga',
|
brand: 'evga',
|
||||||
model: 'xc3 black',
|
model: 'xc3 black',
|
||||||
series: '3080',
|
series: '3080',
|
||||||
url: 'https://www.microcenter.com/product/628340/evga-geforce-rtx-3080-xc3-black-triple-fan-10gb-gddr6x-pcie-40-graphics-card'
|
url: `https://www.microcenter.com/product/628340/evga-geforce-rtx-3080-xc3-black-triple-fan-10gb-gddr6x-pcie-40-graphics-card/?storeid=${storeId}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
brand: 'zotac',
|
brand: 'zotac',
|
||||||
model: 'trinity',
|
model: 'trinity',
|
||||||
series: '3080',
|
series: '3080',
|
||||||
url: 'https://www.microcenter.com/product/628607/zotac-geforce-rtx-3080-trinity-overclocked-triple-fan-10gb-gddr6x-pcie-40-graphics-card'
|
url: `https://www.microcenter.com/product/628607/zotac-geforce-rtx-3080-trinity-overclocked-triple-fan-10gb-gddr6x-pcie-40-graphics-card/?storeid=${storeId}`
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
name: 'microcenter'
|
name: 'microcenter'
|
||||||
|
|||||||
Reference in New Issue
Block a user