Skip to content

Commit

Permalink
feat: adds MediaMarkt Switzerland support
Browse files Browse the repository at this point in the history
  • Loading branch information
timbru31 committed Jul 5, 2024
1 parent 19ea4dc commit efbf1bf
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ You need to put products on your wishlist in order to have this bot working or h
- MediaMarkt Netherlands
- MediaMarkt Poland
- MediaMarkt Spain
- MediaMarkt Switzerland
- MediaWorld Italy
- Saturn

Expand Down Expand Up @@ -105,7 +106,7 @@ Do **not** close the browser window. You can minimize it though.
You can launch the bot directly with a store by supplying the store as an argument

```sh
npm start -- --store <mmat|mmbe|mmde|mmes|mmit|mmnl|mmpl|saturn>
npm start -- --store <mmat|mmbe|mmch|mmde|mmes|mmit|mmnl|mmpl|saturn>
```

### Docker
Expand Down
1 change: 1 addition & 0 deletions src/models/stores/config-model.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface ConfigModel {
mmat: StoreConfiguration;
mmbe: StoreConfiguration;
mmch: StoreConfiguration;
mmde: StoreConfiguration;
mmes: StoreConfiguration;
mmit: StoreConfiguration;
Expand Down
19 changes: 19 additions & 0 deletions src/models/stores/media-markt-switzerland.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { CommonStore } from "./abstract-store";
import type { Store } from "./store";

export class MediaMarktSwitzerland extends CommonStore implements Store {
readonly baseUrl = "https://www.mediamarkt.ch";
readonly countryCode = "CH";
readonly languageCode = "de";
readonly salesLine = "Media";
readonly shortCode = "mmch";
readonly thumbnail = "https://www.mediamarkt.ch/public/manifest/splashscreen-Media-512x512.png";

getName(): string {
return "MediaMarkt Switzerland";
}

getShortName(): string {
return "MediaMarkt";
}
}
12 changes: 12 additions & 0 deletions src/utils/cli-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { MediaMarktGermany } from "../models/stores/media-markt-germany";
import { MediaMarktNetherlands } from "../models/stores/media-markt-netherlands";
import { MediaMarktPoland } from "../models/stores/media-markt-poland";
import { MediaMarktSpain } from "../models/stores/media-markt-spain";
import { MediaMarktSwitzerland } from "../models/stores/media-markt-switzerland";
import { MediaWorldItaly } from "../models/stores/media-world-italy";
import { Saturn } from "../models/stores/saturn";
import type { Store } from "../models/stores/store";
Expand Down Expand Up @@ -41,6 +42,10 @@ export async function getStoreAndStoreConfig(config: ConfigModel): Promise<{
name: "MediaMarkt Belgium",
value: "mediamarkt belgium",
} as ListChoiceOptions,
{
name: "MediaMarkt Switzerland",
value: "mediamarkt switzerland",
} as ListChoiceOptions,
{
name: "MediaMarkt Germany",
value: "mediamarkt germany",
Expand Down Expand Up @@ -87,6 +92,13 @@ export async function getStoreAndStoreConfig(config: ConfigModel): Promise<{
storeConfig = config.mmbe;
store.setSleepTimes(storeConfig.min_sleep_time, storeConfig.max_sleep_time);
break;
case "mmch":
case "mediamarktswitzerland":
case "mediamarkt switzerland":
store = new MediaMarktSwitzerland();
storeConfig = config.mmch;
store.setSleepTimes(storeConfig.min_sleep_time, storeConfig.max_sleep_time);
break;
case "mmde":
case "mediamarktgermany":
case "mediamarkt germany":
Expand Down
4 changes: 2 additions & 2 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { Logger } from "winston";
import { createLogger as createWinstonLogger, format, transports } from "winston";
import type { ConfigModel } from "../models/stores/config-model";

export const GRAPHQL_CLIENT_VERSION = "8.67.2";
export const GRAPHQL_CLIENT_VERSION = "8.99.4";

function getEmojiForLevel(level: string) {
switch (colors.stripColors(level)) {
Expand Down Expand Up @@ -94,7 +94,7 @@ export function shuffle<T>(array: T[]): T[] {
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
export function noop(): void { }
export function noop(): void {}

export async function noopPromise(): Promise<void> {
return Promise.resolve();
Expand Down
3 changes: 2 additions & 1 deletion stores_example.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Valid stores are Saturn (saturn), MediaMarkt Germany (mmde), MediaMarkt Austria (mmat), MediaMarkt Belgium (mmbe), MediaMarkt Spain (mmes), MediaMarkt Netherlands (mmnl), MediaMarkt Poland (mmpl) and MediaWorld Italy (mmit)
# Valid stores are Saturn (saturn), MediaMarkt Germany (mmde), MediaMarkt Austria (mmat), MediaMarkt Belgium (mmbe), MediaMarkt Spain (mmes)
# MediaMarkt Netherlands (mmnl), MediaMarkt Poland (mmpl), MediaMarkt Switzerland (mmch) and MediaWorld Italy (mmit)
[mmde]
# You can define multiple accounts. Make sure to use the first string for the e-mail the second for the password
accounts = [["", ""]]
Expand Down

0 comments on commit efbf1bf

Please sign in to comment.