Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions src/api/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@
import {
DeviceListResponseBody,
DeviceStatusResponseBody,
AnyDevice,
SceneListResponseBody,
SceneExecuteResponseBody,
} from "./types"; // Assuming AnyDevice might be useful for command types
import { isMockMode } from "../appMode";
import { mockSwitchBotBridge } from "./mockSwitchBotBridge";

// We're no longer using direct Axios requests, so we don't need these imports
// import axios, { AxiosInstance, AxiosError, InternalAxiosRequestConfig } from "axios";
// import CryptoJS from "crypto-js";

// We're now using the IPC bridge to communicate with the main process
// const API_BASE_URL = "https://api.switch-bot.com/v1.1";

// Define common command types (can be expanded)
export interface CommandRequestBody {
commandType: "command" | "customize";
Expand Down Expand Up @@ -54,7 +46,6 @@ export class SwitchBotAPI {
private secret: string | null = null;

constructor() {
// No need to initialize axios client or interceptors
// We'll use the IPC bridge to communicate with the main process
}

Comment on lines 48 to 51

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since the constructor is now effectively empty, it can be removed entirely along with the extra newline. TypeScript will provide a default public constructor automatically. This further cleans up the class.

Expand Down Expand Up @@ -205,13 +196,6 @@ export class SwitchBotAPI {
throw new Error(error.message || `An unexpected error occurred while executing scene ${sceneId}`);
}
}

// We no longer need the handleApiError method since we're handling errors directly in each method
// and we're no longer using Axios directly
private handleApiError(error: any) {
console.error("API Error:", error);
throw new Error(error.message || "An unexpected API error occurred.");
}
}

export const switchBotApi = new SwitchBotAPI();