### Setup .env file Source: https://github.com/midday-ai/midday-ts/blob/main/examples/README.md Copies the template environment file to .env, which should then be edited with user credentials. ```bash cp .env.template .env ``` -------------------------------- ### Start Timer Response Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/starttimerresponse.md Demonstrates how to use the StartTimerResponse model from the Midday AI SDK. This example shows the structure of a successful timer start response, including timer details, user information, and project data. ```typescript import { StartTimerResponse } from "@midday-ai/sdk/models/operations"; let value: StartTimerResponse = { data: { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-04-15T09:00:00.000Z", duration: -1, start: "2024-04-15T09:00:00.000Z", stop: "2024-04-15T17:00:00.000Z", teamId: "team-1234", description: "Worked on implementing user authentication feature", rate: 75, currency: "USD", billed: false, date: "2024-04-15", user: { id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", fullName: "Jane Doe", avatarUrl: "https://cdn.midday.ai/avatar.jpg", }, project: { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-03-01T10:00:00.000Z", rate: 75, currency: "USD", status: "in_progress", description: "Complete website redesign with modern UI/UX", name: "Website Redesign Project", billable: true, estimate: 120, customer: { id: "customer-1234", name: "Acme Corporation", }, }, }, }; ``` -------------------------------- ### Get Help for MCP Server Start Command Source: https://github.com/midday-ai/midday-ts/blob/main/README.md Displays the help information for the 'mcp start' command, including available arguments and options for the Midday SDK. ```bash npx -y --package @midday-ai/sdk -- mcp start --help ``` -------------------------------- ### Instantiate and Populate ListCustomersData Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/listcustomersdata.md Demonstrates how to create an instance of the `ListCustomersData` model and populate it with sample customer information. This includes fields like ID, name, email, address, and tags. Ensure the `@midday-ai/sdk` is installed as a dependency. ```typescript import { ListCustomersData } from "@midday-ai/sdk/models/operations"; let value: ListCustomersData = { id: "b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4", name: "Acme Corporation", email: "contact@acme.com", billingEmail: "finance@acme.com", phone: "+1-555-123-4567", website: "https://acme.com", createdAt: "2024-05-01T12:34:56.789Z", country: "United States", addressLine1: "123 Main Street", addressLine2: "Suite 400", city: "San Francisco", state: "California", zip: "94105", note: "Preferred contact method is email. Large enterprise client.", vatNumber: "US123456789", countryCode: "US", token: "cus_abc123xyz789", contact: "John Smith", invoiceCount: 12, projectCount: 3, tags: [ { id: "e7a9c1a2-4c2a-4e7a-9c1a-2b7c1e24c2a4", name: "VIP", }, { id: "f1b2c3d4-5678-4e7a-9c1a-2b7c1e24c2a4", name: "Enterprise", }, ], }; ``` -------------------------------- ### Run Example Script Source: https://github.com/midday-ai/midday-ts/blob/main/examples/README.md Builds the project and executes an example TypeScript file using tsx. Requires Node.js v18+ and npm. ```bash npm run build && npx tsx example.ts ``` -------------------------------- ### Install Midday SDK with Bun Source: https://github.com/midday-ai/midday-ts/blob/main/README.md Installs the Midday TypeScript SDK using the bun package manager. ```bash bun add @midday-ai/sdk ``` -------------------------------- ### Install Midday SDK with NPM Source: https://github.com/midday-ai/midday-ts/blob/main/README.md Installs the Midday TypeScript SDK using the npm package manager. ```bash npm add @midday-ai/sdk ``` -------------------------------- ### Install Midday SDK with PNPM Source: https://github.com/midday-ai/midday-ts/blob/main/README.md Installs the Midday TypeScript SDK using the pnpm package manager. ```bash pnpm add @midday-ai/sdk ``` -------------------------------- ### Application Install URL Configuration Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/getoauthauthorizationresponse.md Provides an optional URL for installing the application. This is a string parameter. ```typescript installUrl: "https://myapp.com/install" ``` -------------------------------- ### TypeScript StartTimerRequest Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/starttimerrequest.md Demonstrates how to create a StartTimerRequest object in TypeScript. This object is used to initiate a timer for a specific project, optionally assigning it to a user, providing a description, setting a start time, or continuing from a previous entry. ```typescript import { StartTimerRequest } from "@midday-ai/sdk/models/operations"; let value: StartTimerRequest = { projectId: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", assignedId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", description: "Working on implementing timer feature", start: new Date("2024-04-15T09:00:00.000Z"), continueFromEntry: "c4d5e6f7-2a3b-4c5d-8e9f-3a4b5c6d7e8f", }; ``` -------------------------------- ### TypeScript ListCustomersResponse Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/listcustomersresponse.md Demonstrates how to import and use the ListCustomersResponse model in TypeScript. This example shows the structure of the response, including meta for pagination and a data array containing customer details. ```typescript import { ListCustomersResponse } from "@midday-ai/sdk/models/operations"; let value: ListCustomersResponse = { meta: { cursor: "eyJpZCI6IjQ1NiJ9", hasPreviousPage: false, hasNextPage: true, }, data: [ { id: "b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4", name: "Acme Corporation", email: "contact@acme.com", billingEmail: "finance@acme.com", phone: "+1-555-123-4567", website: "https://acme.com", createdAt: "2024-05-01T12:34:56.789Z", country: "United States", addressLine1: "123 Main Street", addressLine2: "Suite 400", city: "San Francisco", state: "California", zip: "94105", note: "Preferred contact method is email. Large enterprise client.", vatNumber: "US123456789", countryCode: "US", token: "cus_abc123xyz789", contact: "John Smith", invoiceCount: 12, projectCount: 3, tags: [ { id: "e7a9c1a2-4c2a-4e7a-9c1a-2b7c1e24c2a4", name: "VIP", }, { id: "f1b2c3d4-5678-4e7a-9c1a-2b7c1e24c2a4", name: "Enterprise", }, ], }, ], }; ``` -------------------------------- ### Install Midday SDK with Yarn Source: https://github.com/midday-ai/midday-ts/blob/main/README.md Installs the Midday TypeScript SDK and its peer dependency 'zod' using the yarn package manager. ```bash yarn add @midday-ai/sdk zod ``` -------------------------------- ### Instantiate and Populate Result Model Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/result.md Demonstrates how to create an instance of the `Result` model from the `@midday-ai/sdk/models/operations` package. The example shows the structure and expected data types for properties like IDs, timestamps, duration, billing information, and nested user and project objects. ```typescript import { Result } from "@midday-ai/sdk/models/operations"; let value: Result = { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-04-15T09:00:00.000Z", duration: 28800, start: "2024-04-15T09:00:00.000Z", stop: "2024-04-15T17:00:00.000Z", teamId: "team-1234", description: "Worked on implementing user authentication feature", rate: 75, currency: "USD", billed: false, date: "2024-04-15", user: { id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", fullName: "Jane Doe", avatarUrl: "https://cdn.midday.ai/avatar.jpg", }, project: { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2023-03-01T10:00:00.000Z", rate: 75, currency: "USD", status: "in_progress", description: "Complete website redesign with modern UI/UX", name: "Website Redesign Project", billable: true, estimate: 120, customer: { id: "customer-1234", name: "Acme Corporation", }, }, }; ``` -------------------------------- ### TypeScript GetProfitResponseSchema Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/getprofitresponseschema.md Demonstrates how to use the GetProfitResponseSchema from the Midday AI SDK. This example shows the structure of a profit response, including summary, meta, and result details. ```typescript import { GetProfitResponseSchema } from "@midday-ai/sdk/models"; let value: GetProfitResponseSchema = { summary: { currentTotal: 10000, prevTotal: 8000, currency: "USD", }, meta: { type: "profit", currency: "USD", }, result: [ { date: "2023-01-31", percentage: { value: 25, status: "positive", }, current: { date: "2023-01-31", value: 1000, currency: "USD", }, previous: { date: "2022-01-31", value: 800, currency: "USD", }, }, ], }; ``` -------------------------------- ### TypeScript GetCurrentTimerProject Model Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/getcurrenttimerproject.md Demonstrates how to import and use the GetCurrentTimerProject model from the Midday AI SDK. The example shows the structure of the project information, including details like ID, creation date, rate, currency, status, description, name, billable status, estimate, and associated customer information. ```typescript import { GetCurrentTimerProject } from "@midday-ai/sdk/models/operations"; let value: GetCurrentTimerProject = { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-03-01T10:00:00.000Z", rate: 75, currency: "USD", status: "in_progress", description: "Complete website redesign with modern UI/UX", name: "Website Redesign Project", billable: true, estimate: 120, customer: { id: "customer-1234", name: "Acme Corporation", }, }; ``` -------------------------------- ### Configure Standalone MCP Server Source: https://github.com/midday-ai/midday-ts/blob/main/README.md Configures a standalone MCP server, specifying its command path and arguments for starting the server. ```json { "mcpServers": { "Todos": { "command": "./DOWNLOAD/PATH/mcp-server", "args": [ "start" ] } } } ``` -------------------------------- ### TypeScript UpdateBankAccountResponse Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/updatebankaccountresponse.md Demonstrates how to create an instance of the UpdateBankAccountResponse model in TypeScript, initializing it with sample bank account data. ```typescript import { UpdateBankAccountResponse } from "@midday-ai/sdk/models/operations"; let value: UpdateBankAccountResponse = { id: "b7e6c2a0-1f2d-4c3b-9a8e-123456789abc", name: "Checking Account", currency: "USD", type: "depository", enabled: true, balance: 1500.75, manual: false, }; ``` -------------------------------- ### GetExpensesResponseSchemaMeta Usage Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/getexpensesresponseschemameta.md Demonstrates how to import and instantiate the GetExpensesResponseSchemaMeta model with sample data for expense type and currency. ```typescript import { GetExpensesResponseSchemaMeta } from "@midday-ai/sdk/models"; let value: GetExpensesResponseSchemaMeta = { type: "expense", currency: "SEK", }; ``` -------------------------------- ### Get Revenue Metrics (TypeScript) Source: https://github.com/midday-ai/midday-ts/blob/main/docs/sdks/metrics/README.md Retrieves revenue metrics for the authenticated team within a specified date range and currency. This example uses the main SDK client. ```typescript import { Midday } from "@midday-ai/sdk"; const midday = new Midday({ security: { oauth2: process.env["MIDDAY_OAUTH2"] ?? "", }, }); async function run() { const result = await midday.metrics.revenue({ from: "2023-01-01", to: "2023-12-31", currency: "USD", }); console.log(result); } run(); ``` -------------------------------- ### Get Team by ID (TypeScript) Source: https://github.com/midday-ai/midday-ts/blob/main/docs/sdks/teams/README.md Retrieves a specific team using its unique identifier. This example demonstrates the standard method call within the Midday SDK, requiring authentication via OAuth2. ```typescript import { Midday } from "@midday-ai/sdk"; const midday = new Midday({ security: { oauth2: process.env["MIDDAY_OAUTH2"] ?? "", }, }); async function run() { const result = await midday.teams.get({ id: "123e4567-e89b-12d3-a456-426614174000", }); console.log(result); } run(); ``` -------------------------------- ### Get Inbox Item by ID using Midday SDK Source: https://github.com/midday-ai/midday-ts/blob/main/docs/sdks/inbox/README.md Retrieves a specific inbox item using its unique identifier. This example utilizes the main Midday SDK client and requires OAuth2 authentication. ```typescript import { Midday } from "@midday-ai/sdk"; const midday = new Midday({ security: { oauth2: process.env["MIDDAY_OAUTH2"] ?? "", }, }); async function run() { const result = await midday.inbox.get({ id: "b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4", }); console.log(result); } run(); ``` -------------------------------- ### Instantiate ListInvoicesCustomer Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/listinvoicescustomer.md Demonstrates how to create an instance of the ListInvoicesCustomer model with essential customer details like ID, name, website, and email. ```typescript import { ListInvoicesCustomer } from "@midday-ai/sdk/models/operations"; let value: ListInvoicesCustomer = { id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", name: "Acme Corporation", website: "https://acme.com", email: "info@acme.com", }; ``` -------------------------------- ### Get Tracker Project by ID using Standalone Function Source: https://github.com/midday-ai/midday-ts/blob/main/docs/sdks/trackerprojects/README.md This example demonstrates fetching a tracker project using a standalone function from the Midday SDK core. It emphasizes tree-shaking performance and handles successful responses and errors. ```typescript import { MiddayCore } from "@midday-ai/sdk/core.js"; import { trackerProjectsGet } from "@midday-ai/sdk/funcs/trackerProjectsGet.js"; // Use `MiddayCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const midday = new MiddayCore({ security: { oauth2: process.env["MIDDAY_OAUTH2"] ?? "", }, }); async function run() { const res = await trackerProjectsGet(midday, { id: "b7e6c8e2-1f2a-4c3b-9e2d-1a2b3c4d5e6f", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("trackerProjectsGet failed:", res.error); } } run(); ``` -------------------------------- ### Get OAuth Authorization with Midday TS SDK Source: https://github.com/midday-ai/midday-ts/blob/main/USAGE.md This snippet shows how to initialize the Midday TypeScript SDK and request OAuth authorization. It requires setting up security credentials, likely an OAuth2 token, and provides parameters such as `responseType`, `clientId`, `redirectUri`, `scope`, `state`, and `codeChallenge`. ```typescript import { Midday } from "@midday-ai/sdk"; const midday = new Midday({ security: { oauth2: process.env["MIDDAY_OAUTH2"] ?? "", }, }); async function run() { const result = await midday.oAuth.getOAuthAuthorization({ responseType: "code", clientId: "mid_client_abcdef123456789", redirectUri: "https://myapp.com/callback", scope: "transactions.read invoices.read", state: "abc123xyz789_secure-random-state-value-with-sufficient-entropy", codeChallenge: "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM", }); console.log(result); } run(); ``` -------------------------------- ### Create Tracker Entry Request Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/createtrackerentryrequest.md Demonstrates how to create a CreateTrackerEntryRequest object in TypeScript. This object is used to define the parameters for creating a new tracker entry, including start and stop times, associated dates, assigned user ID, project ID, an optional description, and the duration in seconds. ```typescript import { CreateTrackerEntryRequest } from "@midday-ai/sdk/models/operations"; let value: CreateTrackerEntryRequest = { start: new Date("2024-04-15T09:00:00.000Z"), stop: new Date("2024-04-15T17:00:00.000Z"), dates: [ "2024-04-15", "2024-04-16", ], assignedId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", projectId: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", description: "Worked on implementing user authentication feature", duration: 28800, }; ``` -------------------------------- ### Instantiate CreateCustomerRequest Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/createcustomerrequest.md Demonstrates how to create an instance of the CreateCustomerRequest object and populate its fields with sample customer data. This includes basic customer information, address details, contact information, and tags. ```typescript import { CreateCustomerRequest } from "@midday-ai/sdk/models/operations"; let value: CreateCustomerRequest = { id: "b3b7c1e2-4c2a-4e7a-9c1a-2b7c1e24c2a4", name: "Acme Corporation", email: "contact@acme.com", billingEmail: "finance@acme.com", country: "United States", addressLine1: "123 Main Street", addressLine2: "Suite 400", city: "San Francisco", state: "California", zip: "94105", phone: "+1-555-123-4567", website: "https://acme.com", note: "Preferred contact method is email. Large enterprise client.", vatNumber: "US123456789", countryCode: "US", contact: "John Smith", tags: [ { id: "e7a9c1a2-4c2a-4e7a-9c1a-2b7c1e24c2a4", name: "VIP", }, { id: "f1b2c3d4-5678-4e7a-9c1a-2b7c1e24c2a4", name: "Enterprise", }, ], }; ``` -------------------------------- ### Get Tag by ID using Standalone Function (Midday TS SDK) Source: https://github.com/midday-ai/midday-ts/blob/main/docs/sdks/tags/README.md This example demonstrates fetching a tag by its ID using a standalone function from the Midday TypeScript SDK. It utilizes `MiddayCore` for optimized tree-shaking and the `tagsGet` function. The code handles both successful responses and potential errors, logging the tag data or the error message accordingly. ```typescript import { MiddayCore } from "@midday-ai/sdk/core.js"; import { tagsGet } from "@midday-ai/sdk/funcs/tagsGet.js"; // Use `MiddayCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const midday = new MiddayCore({ security: { oauth2: process.env["MIDDAY_OAUTH2"] ?? "", }, }); async function run() { const res = await tagsGet(midday, { id: "b3b7c8e2-1f2a-4c3d-9e4f-5a6b7c8d9e0f", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("tagsGet failed:", res.error); } } run(); ``` -------------------------------- ### Instantiate GetInvoiceByIdCustomer Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/getinvoicebyidcustomer.md Demonstrates how to create an instance of the GetInvoiceByIdCustomer model with essential customer information like ID, name, website, and email. ```typescript import { GetInvoiceByIdCustomer } from "@midday-ai/sdk/models/operations"; let value: GetInvoiceByIdCustomer = { id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", name: "Acme Corporation", website: "https://acme.com", email: "info@acme.com", }; ``` -------------------------------- ### Create Tracker Entry Data Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/createtrackerentrydata.md Demonstrates how to instantiate and populate the CreateTrackerEntryData model with sample data. This includes essential fields like ID, timestamps, duration, team ID, description, billing information, and associated user and project details. ```typescript import { CreateTrackerEntryData } from "@midday-ai/sdk/models/operations"; let value: CreateTrackerEntryData = { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-04-15T09:00:00.000Z", duration: 28800, start: "2024-04-15T09:00:00.000Z", stop: "2024-04-15T17:00:00.000Z", teamId: "team-1234", description: "Worked on implementing user authentication feature", rate: 75, currency: "USD", billed: false, date: "2024-04-15", user: { id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", fullName: "Jane Doe", avatarUrl: "https://cdn.midday.ai/avatar.jpg", }, project: { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-03-01T10:00:00.000Z", rate: 75, currency: "USD", status: "in_progress", description: "Complete website redesign with modern UI/UX", name: "Website Redesign Project", billable: true, estimate: 120, customer: { id: "customer-1234", name: "Acme Corporation", }, }, }; ``` -------------------------------- ### Start Timer - Midday TS SDK Source: https://github.com/midday-ai/midday-ts/blob/main/docs/sdks/trackertimer/README.md Starts a new timer or continues a paused timer. Requires project and assigned IDs, and optionally a description and start time. Can also specify a `continueFromEntry` ID to resume a previous entry. ```typescript import { Midday } from "@midday-ai/sdk"; const midday = new Midday({ security: { oauth2: process.env["MIDDAY_OAUTH2"] ?? "", }, }); async function run() { const result = await midday.trackerTimer.startTimer({ projectId: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", assignedId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", description: "Working on implementing timer feature", start: new Date("2024-04-15T09:00:00.000Z"), continueFromEntry: "c4d5e6f7-2a3b-4c5d-8e9f-3a4b5c6d7e8f", }); console.log(result); } run(); ``` ```typescript import { MiddayCore } from "@midday-ai/sdk/core.js"; import { trackerTimerStartTimer } from "@midday-ai/sdk/funcs/trackerTimerStartTimer.js"; // Use `MiddayCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const midday = new MiddayCore({ security: { oauth2: process.env["MIDDAY_OAUTH2"] ?? "", }, }); async function run() { const res = await trackerTimerStartTimer(midday, { projectId: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", assignedId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", description: "Working on implementing timer feature", start: new Date("2024-04-15T09:00:00.000Z"), continueFromEntry: "c4d5e6f7-2a3b-4c5d-8e9f-3a4b5c6d7e8f", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("trackerTimerStartTimer failed:", res.error); } } run(); ``` -------------------------------- ### Instantiate ListTrackerEntriesProject in TypeScript Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/listtrackerentriesproject.md Demonstrates how to create and initialize a ListTrackerEntriesProject object with sample data. This includes setting properties like ID, creation date, rate, currency, status, description, name, billable status, estimate, and customer details. ```TypeScript import { ListTrackerEntriesProject } from "@midday-ai/sdk/models/operations"; let value: ListTrackerEntriesProject = { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-03-01T10:00:00.000Z", rate: 75, currency: "USD", status: "in_progress", description: "Complete website redesign with modern UI/UX", name: "Website Redesign Project", billable: true, estimate: 120, customer: { id: "customer-1234", name: "Acme Corporation", }, }; ``` -------------------------------- ### RevenueSummary Model Usage (TypeScript) Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/revenuesummary.md Demonstrates how to instantiate and use the RevenueSummary model from the Midday AI SDK. It shows the structure for current and previous total revenue, along with the currency. ```TypeScript import { RevenueSummary } from "@midday-ai/sdk/models"; let value: RevenueSummary = { currentTotal: 10000, prevTotal: 8000, currency: "USD", }; ``` -------------------------------- ### UpdateTrackerEntryProject Model Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/updatetrackerentryproject.md Demonstrates how to create an instance of the UpdateTrackerEntryProject model with sample data. This model represents project information for a tracker entry, including details like ID, creation date, rate, currency, status, description, name, billable status, estimate, and customer. ```typescript import { UpdateTrackerEntryProject } from "@midday-ai/sdk/models/operations"; let value: UpdateTrackerEntryProject = { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-03-01T10:00:00.000Z", rate: 75, currency: "USD", status: "in_progress", description: "Complete website redesign with modern UI/UX", name: "Website Redesign Project", billable: true, estimate: 120, customer: null, }; ``` -------------------------------- ### Instantiate StartTimerUser Model Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/starttimeruser.md Demonstrates how to create an instance of the StartTimerUser model with required fields like id, fullName, and avatarUrl. ```typescript import { StartTimerUser } from "@midday-ai/sdk/models/operations"; let value: StartTimerUser = { id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", fullName: "Jane Doe", avatarUrl: "https://cdn.midday.ai/avatar.jpg", }; ``` -------------------------------- ### TypeScript GetDocumentByIdResponse Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/getdocumentbyidresponse.md Demonstrates how to import and use the GetDocumentByIdResponse type from the Midday AI SDK to create a document object. This example shows the structure and expected values for each field. ```TypeScript import { GetDocumentByIdResponse } from "@midday-ai/sdk/models/operations"; let value: GetDocumentByIdResponse = { id: "doc_1234567890abcdef", title: "Invoice April 2024", pathTokens: [ "invoices", "2024", "april", "invoice-123.pdf", ], metadata: { size: 204800, mimetype: "application/pdf", }, processingStatus: "processed", summary: "Invoice for April 2024, total $1,200.00", date: "2024-04-30", }; ``` -------------------------------- ### CreateTrackerEntryProject Model Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/createtrackerentryproject.md Demonstrates how to create and populate a CreateTrackerEntryProject object using the Midday AI SDK in TypeScript. This includes defining project details like ID, timestamps, rates, status, and descriptions. ```typescript import { CreateTrackerEntryProject } from "@midday-ai/sdk/models/operations"; let value: CreateTrackerEntryProject = { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-03-01T10:00:00.000Z", rate: 75, currency: "USD", status: "in_progress", description: "Complete website redesign with modern UI/UX", name: "Website Redesign Project", billable: true, estimate: 120, customer: null, }; ``` -------------------------------- ### TypeScript GetBankAccountByIdResponse Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/getbankaccountbyidresponse.md This example demonstrates how to import and use the GetBankAccountByIdResponse model from the Midday AI SDK in TypeScript. It shows the structure of a typical response object for a bank account. ```TypeScript import { GetBankAccountByIdResponse } from "@midday-ai/sdk/models/operations"; let value: GetBankAccountByIdResponse = { id: "b7e6c2a0-1f2d-4c3b-9a8e-123456789abc", name: "Checking Account", currency: "USD", type: "depository", enabled: true, balance: 1500.75, manual: false, }; ``` -------------------------------- ### UpdateTrackerEntryData Example Usage Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/updatetrackerentrydata.md Demonstrates the structure and usage of the UpdateTrackerEntryData model. This includes essential fields for tracking time, billing, and associating entries with users and projects. ```typescript import { UpdateTrackerEntryData } from "@midday-ai/sdk/models/operations"; let value: UpdateTrackerEntryData = { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-04-15T09:00:00.000Z", duration: 28800, start: "2024-04-15T09:00:00.000Z", stop: "2024-04-15T17:00:00.000Z", teamId: "team-1234", description: "Worked on implementing user authentication feature", rate: 75, currency: "USD", billed: false, date: "2024-04-15", user: { id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", fullName: "Jane Doe", avatarUrl: "https://cdn.midday.ai/avatar.jpg", }, project: { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-03-01T10:00:00.000Z", rate: 75, currency: "USD", status: "in_progress", description: "Complete website redesign with modern UI/UX", name: "Website Redesign Project", billable: true, estimate: 120, customer: { id: "customer-1234", name: "Acme Corporation", }, }, }; ``` -------------------------------- ### TypeScript CurrentEntry Model Usage Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/currententry.md Demonstrates how to import and instantiate the CurrentEntry model from the Midday AI TypeScript SDK. This example shows the structure of a running timer entry, including project details. ```typescript import { CurrentEntry } from "@midday-ai/sdk/models/operations"; let value: CurrentEntry = { id: "85e7df6e-c9d2-4efb-b7f9-abb5f57ba94b", start: "", description: "seafood often sick repurpose bug", projectId: "34f0d89b-9766-4eae-b93a-2c8b5607eff0", trackerProject: { id: "0aa650ab-697e-4edd-9fd6-c05268ab3be7", name: "", }, }; ``` -------------------------------- ### Get Revenue Metrics Request Source: https://github.com/midday-ai/midday-ts/blob/main/docs/sdks/metrics/README.md This snippet demonstrates how to construct a request to get revenue metrics. It includes the required request object and optional parameters for fetch options and retry configurations. ```typescript import { operations } from "../models/operations"; import { RequestOptions } from "../lib/request"; // Example usage: const request: operations.GetRevenueMetricsRequest = { // ... populate with your request data }; const options: RequestOptions = { fetchOptions: { headers: { "X-Custom-Header": "example-value" } }, retries: { attempts: 3, backoff: "exponential" } }; // Assuming a client instance 'middayClient' is available: // middayClient.analytics.getRevenueMetrics(request, options); ``` -------------------------------- ### GetCurrentTimerResponse Example Usage (TypeScript) Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/operations/getcurrenttimerresponse.md Demonstrates how to import and use the GetCurrentTimerResponse model in TypeScript. This example shows the structure of a successful response, including timer details, user information, and project data. ```typescript import { GetCurrentTimerResponse } from "@midday-ai/sdk/models/operations"; let value: GetCurrentTimerResponse = { data: { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-04-15T09:00:00.000Z", duration: -1, start: "2024-04-15T09:00:00.000Z", stop: "2024-04-15T17:00:00.000Z", teamId: "team-1234", description: "Worked on implementing user authentication feature", rate: 75, currency: "USD", billed: false, date: "2024-04-15", user: { id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", fullName: "Jane Doe", avatarUrl: "https://cdn.midday.ai/avatar.jpg", }, project: { id: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2", createdAt: "2024-03-01T10:00:00.000Z", rate: 75, currency: "USD", status: "in_progress", description: "Complete website redesign with modern UI/UX", name: "Website Redesign Project", billable: true, estimate: 120, customer: { id: "customer-1234", name: "Acme Corporation", }, }, }, }; ``` -------------------------------- ### GetRevenueResponseSchema Usage Example (TypeScript) Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/getrevenueresponseschema.md This snippet shows how to import and use the GetRevenueResponseSchema from the Midday AI SDK to define a revenue data structure. It includes example data for summary, meta, and result fields. ```typescript import { GetRevenueResponseSchema } from "@midday-ai/sdk/models"; let value: GetRevenueResponseSchema = { summary: { currentTotal: 10000, prevTotal: 8000, currency: "USD", }, meta: { type: "revenue", currency: "USD", }, result: [ { date: "2023-01-31", percentage: { value: 25, status: "positive", }, current: { date: "2023-01-31", value: 1000, currency: "USD", }, previous: { date: "2022-01-31", value: 800, currency: "USD", }, }, ], }; ``` -------------------------------- ### Instantiate Security Model with Token Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/security.md Demonstrates how to import and create an instance of the Security model from the Midday TS SDK, initializing it with an API token. ```typescript import { Security } from "@midday-ai/sdk/models"; let value: Security = { token: "MIDDAY_API_KEY", }; ``` -------------------------------- ### Get Profit Metrics Request Source: https://github.com/midday-ai/midday-ts/blob/main/docs/sdks/metrics/README.md This snippet demonstrates how to construct and send a request to get profit metrics. It utilizes the `operations.GetProfitMetricsRequest` type and allows for optional request configurations like fetch options and retry settings. ```typescript import { operations } from "../models/operations"; import { RequestOptions } from "../lib/request"; // Example usage: const requestParams: operations.GetProfitMetricsRequest = { // ... populate with your request data }; const options: RequestOptions = { fetchOptions: { headers: { "X-Custom-Header": "example-value" } }, retries: { attempts: 3 } }; // Assuming 'middayClient' is an instance of the Midday client // middayClient.getProfitMetrics(requestParams, options) // .then(response => { // console.log(response); // }) // .catch(error => { // console.error(error); // }); ``` -------------------------------- ### TypeScript Customer Model Example Source: https://github.com/midday-ai/midday-ts/blob/main/docs/models/customer.md Demonstrates how to import and create a Customer object using the Midday AI SDK in TypeScript. The Customer model includes fields for ID, name, and website. ```typescript import { Customer } from "@midday-ai/sdk/models"; let value: Customer = { id: "a1b2c3d4-e5f6-7890-abcd-1234567890ef", name: "Acme Corporation", website: "https://acme.com", }; ```