### Making Synchronous HTTP Request (Utils API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Performs a synchronous HTTP request to the specified URL using the given method (e.g., 'GET', 'POST'). Optional headers and parameters can be included. Returns an object containing the status code, result body as a string, and response headers. Standard headers like Content-Type and Accept can be overridden. ```javascript utils.request(url, method, headers, parameters) ``` -------------------------------- ### Querying Time Entries (Tyme API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Retrieves a list of time entries based on specified criteria. Parameters include start and end dates (mandatory), optional task IDs, limit, billing state (0=unbilled, 1=billed, 2=paid), billable status, user ID, and a clustering option (0=none, 1=cluster by task & day). Returns an array of time entry objects with detailed properties. ```javascript tyme.timeEntries(start, end, taskIDs, limit, billingState, billable, userID) ``` -------------------------------- ### Getting Currency Symbol (Tyme API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Returns the currency symbol (e.g., "€", "$") currently configured in Tyme. ```javascript tyme.currencySymbol() ``` -------------------------------- ### Getting Secure Value (Tyme API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Retrieves a value previously stored in the local device's keychain using the specified key. ```javascript tyme.getSecureValue(key) ``` -------------------------------- ### Getting Currency Code (Tyme API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Returns the three-letter currency code (e.g., "EUR", "USD") currently configured in Tyme. ```javascript tyme.currencyCode() ``` -------------------------------- ### Updating Tyme Plugin Form Elements (JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/README.md Provides examples of how to dynamically update the properties of rendered form elements from the plugin script using the global `formElement` object and the element's unique ID. It shows how to change visibility (`isHidden`), enable/disable state (`enabled`), and reload dropdown data (`reload()`). The updates are often based on other form values. ```JavaScript // update a form element formElement.someUniqueID.isHidden = !formValue.includeNonBillable; formElement.someUniqueID.enabled = !formValue.markAsBilled; formElement.someUniqueID.reload(); ``` -------------------------------- ### Creating and Linking Category and Project in Tyme Plugin Source: https://github.com/tyme-app/plugins/blob/main/guides/importing_data.md This snippet demonstrates how to create or retrieve a Category object by ID, set its name, then create a Project object by ID, set its name, and link it to the Category. It uses the Category.fromID and Category.create static methods, and the Project.create static method. ```javascript const id = "prefix_id1"; let category = Category.fromID(id) ?? Category.create(id); category.name = "My Category"; let project = Project.create("prefix_id2"); project.name = "My Project"; project.category = category; ``` -------------------------------- ### Opening File Selection Dialog (Tyme API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Displays a dialog allowing the user to select a file from their disk. Parameters include the dialog title, an array of allowed file extensions (can be empty), and a callback function that receives the file contents as an argument. ```javascript tyme.selectFile(title, fileTypes, resultFunction) ``` -------------------------------- ### Tyme Plugin Project Class Definition Source: https://github.com/tyme-app/plugins/blob/main/guides/importing_data.md Defines the structure and available methods for the Project class used in Tyme plugins. It includes properties for project details, planning, tracking, dates, and its associated category, along with static methods for creation (create) and retrieval (fromID), and an instance method for deletion (delete). ```javascript class Project { id // string name // string isCompleted // bool color // numeric value (0x334455) defaultHourlyRate // float plannedBudget // float plannedDuration // int, seconds trackingMode // int, 0=slot, 1=cluster startDate // date, optional dueDate // date, optional category // the category the project is contained in static create(id) static fromID(id) delete() } ``` -------------------------------- ### Tyme Plugin Manifest (plugin.json) Source: https://github.com/tyme-app/plugins/blob/main/README.md Defines the structure and required fields for the plugin.json file, which configures the plugin's metadata, compatibility, type (export/import), author information, icon, and entry points for the main script and preview function. ```JSON { "id": "unique_id_of_your_plugin", "tymeMinVersion": "2024.1", // the minimum compatible version of Tyme for this plugin "version": "1.0", "type": "[export|import]", "author": "John Doe", "authorUrl": "https://www.tyme-app.com", "icon": "some_icon92x92.png", "scriptName": "script.js", "scriptMain": "createInvoice()", // the method to call when exporting "scriptPreview": "generatePreview()", // the method to call when generating a preview (HTML is expected in return), only export plugins "formName": "form.json", "localizationName": "localization.json" } ``` -------------------------------- ### Tyme Plugin Folder Location Source: https://github.com/tyme-app/plugins/blob/main/README.md Specifies the default directory path where custom Tyme plugins should be placed on macOS. ```Path ~/Library/Containers/com.tyme-app.Tyme3-macOS/Data/Library/Application Support/plugins/[YOUR_PLUGIN_FOLDER]/ ``` -------------------------------- ### Localization File Structure - JSON Source: https://github.com/tyme-app/plugins/blob/main/README.md Defines the structure for localization files used by the plugin. It includes required fields like plugin name and summary, along with specific input field labels and placeholders for different languages (English and German). ```JSON { "en": { "plugin.name": "Awesome Plugin", // required "plugin.summary": "This is what the plugin does…", // required "input.key": "Secret Key", "input.key.placeholder": "Please enter your personal key", … }, "de": { "plugin.name": "Geniales Plugin", // required "plugin.summary": "Dieses Plugin macht Folgendes…", // required "input.key": "Geheimer Schlüssel", "input.key.placeholder": "Bitte gib deinen persönlichen Schlüssel ein", … } } ``` -------------------------------- ### Opening URL (Tyme API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Opens the specified URL in the user's default web browser. ```javascript tyme.openURL(url) ``` -------------------------------- ### Opening Save Dialog (Tyme API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Presents a dialog to the user, prompting them to choose a location and filename to save the provided content to a file. ```javascript tyme.openSaveDialog(fileName, content) ``` -------------------------------- ### Tyme Plugin TimedTask Class Definition Source: https://github.com/tyme-app/plugins/blob/main/guides/importing_data.md Defines the structure and available methods for the TimedTask class used in Tyme plugins. It includes properties for task details, billing, rounding, planning, dates, and its associated project, along with static methods for creation (create) and retrieval (fromID), and an instance method for deletion (delete). ```javascript class TimedTask { id // string name // string isCompleted // bool billable // bool hourlyRate // float roundingMethod // int, down=0, nearest=1, up=2 roundingMinutes // int plannedBudget // float plannedDuration // int, seconds startDate // date, optional dueDate // date, optional project // the project the task is contained in static create(id) static fromID(id) delete() } ``` -------------------------------- ### Tyme Plugin TimedSubtask Class Definition Source: https://github.com/tyme-app/plugins/blob/main/guides/importing_data.md Defines the structure and available methods for the TimedSubtask class used in Tyme plugins. It includes properties for subtask details, billing, planning, dates, and its parent task, along with static methods for creation (create) and retrieval (fromID), and an instance method for deletion (delete). ```javascript class TimedSubtask { id // string name // string isCompleted // bool billable // bool hourlyRate // float plannedBudget // float plannedDuration // int, seconds startDate // date, optional dueDate // date, optional parentTask // the task the sub-task is contained in static create(id) static fromID(id) delete() } ``` -------------------------------- ### Tyme Plugin TimeEntry Class Definition Source: https://github.com/tyme-app/plugins/blob/main/guides/importing_data.md Defines the structure and available methods for the TimeEntry class used in Tyme plugins. It includes properties for entry details, billing state, notes, start/end times, user ID, and its parent task, along with static methods for creation (create) and retrieval (fromID), and an instance method for deletion (delete). ```javascript class TimeEntry { id // string billingState // unbilled=0, billed=1, paid=2 note // string timeStart // date timeEnd // date userID // string, optional parentTask // the task the entry is contained in static create(id) static fromID(id) delete() } ``` -------------------------------- ### Defining Tyme Plugin Form Value Function (JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/README.md Shows how to implement a JavaScript function (`getClients`) that serves as a `valueFunction` for a dropdown form element. Tyme calls this function to retrieve an array of name-value pairs, which are then used to populate the dropdown options dynamically. ```JavaScript getClients() { return [ { "name": "Name", "value": "some_value" } ]; } ``` -------------------------------- ### Tyme Plugin Form Definition (form.json) Source: https://github.com/tyme-app/plugins/blob/main/README.md Illustrates the JSON structure for defining user-configurable options within a plugin form. It details various element types (button, text, date, dropdown, etc.), their properties like ID, name, placeholder, persistence, initial value, action functions, and value functions for dynamic content. ```JSON [ { "id": "someUniqueID", "type": "[button|securetext|text|separator|date|daterange|teammembers|tasks|checkbox|dropdown]", "name": "label or localization key", "placeholder": "label or localization key", // only text "persist": false, "value": "initial value", "values": [ // only dropdown {"key1": "label or localization key"}, {"key1": "label or localization key"} ], "actionFunction": "openWebsite()", // all elements, except of separator "valueFunction": "getClients()", // only dropdown "valueFunctionReloadable": true // shows a button to reload the dropdown }, ] // 2024.5: 'daterange' type added // 2024.5: 'actionFunction' for all elements added (Previously only button). // Please set the tymeMinVersion to 2024.5 if you plan to use the above features. ``` -------------------------------- ### Writing to File (Utils API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Writes the provided content to a file within the plugin's sandboxed folder. If the file exists, it will be overwritten. File access is strictly limited to this directory. ```javascript utils.writeToFile(fileName, content) ``` -------------------------------- ### Showing Alert Dialog (Tyme API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Displays a standard alert dialog to the user with a specified title and message. ```javascript tyme.showAlert(title, message) ``` -------------------------------- ### Converting Markdown to HTML (Utils API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Converts a string formatted with Markdown syntax into an HTML string. ```javascript utils.markdownToHTML(markdown) ``` -------------------------------- ### Reading File Content (Utils API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Loads the content of a file from the plugin's sandboxed folder and returns it as a string. File access is strictly limited to this directory. ```javascript utils.contentsOfFile(fileName) ``` -------------------------------- ### Tyme Plugin Expense Class Definition Source: https://github.com/tyme-app/plugins/blob/main/guides/importing_data.md Defines the structure and available methods for the Expense class used in Tyme plugins. It includes properties for expense details, notes, billing, quantity, price, purchase date, user ID, and its associated group, along with static methods for creation (create) and retrieval (fromID), and an instance method for deletion (delete). ```javascript class Expense { id // string name // string note // string isCompleted // bool billable // bool quantity // float price // float purchaseDate // date userID // string, optional group // the group the expense is contained in static create(id) static fromID(id) delete() } ``` -------------------------------- ### Tyme Plugin ExpenseGroup Class Definition Source: https://github.com/tyme-app/plugins/blob/main/guides/importing_data.md Defines the structure and available methods for the ExpenseGroup class used in Tyme plugins. It includes properties for group details, billing, planned budget, and its associated project, along with static methods for creation (create) and retrieval (fromID), and an instance method for deletion (delete). ```javascript class ExpenseGroup { id // string name // string isCompleted // bool billable // bool plannedBudget // float project // the project the group is contained in static create(id) static fromID(id) delete() } ``` -------------------------------- ### Tyme Plugin Category Class Definition Source: https://github.com/tyme-app/plugins/blob/main/guides/importing_data.md Defines the structure and available methods for the Category class used in Tyme plugins. It includes properties like id, name, color, and isCompleted, and static methods for creating (create) and retrieving (fromID) categories, as well as an instance method for deletion (delete). ```javascript class Category { id // string name // string color // numeric value (0x334455) isCompleted // bool static create(id) static fromID(id) delete() } ``` -------------------------------- ### Tyme Plugin MileageTask Class Definition Source: https://github.com/tyme-app/plugins/blob/main/guides/importing_data.md Defines the structure and available methods for the MileageTask class used in Tyme plugins. It includes properties for task details, billing, kilometer rate, planned budget, and its associated project, along with static methods for creation (create) and retrieval (fromID), and an instance method for deletion (delete). ```javascript class MileageTask { id // string name // string isCompleted // bool billable // bool kilometerRate // float, kilometers plannedBudget // float project // the project the task is contained in static create(id) static fromID(id) delete() } ``` -------------------------------- ### Tyme Plugin MileageEntry Class Definition Source: https://github.com/tyme-app/plugins/blob/main/guides/importing_data.md Defines the structure and available methods for the MileageEntry class used in Tyme plugins. It includes properties for entry details, billing state, distance, notes, start/end times, user ID, and its parent task, along with static methods for creation (create) and retrieval (fromID), and an instance method for deletion (delete). ```javascript class MileageEntry { id // string billingState // unbilled=0, billed=1, paid=2 traveledDistance // float, kilometers note // string timeStart // date timeEnd // date userID // string, optional parentTask // the task the entry is contained in static create(id) static fromID(id) delete() } ``` -------------------------------- ### Setting Secure Value (Tyme API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Stores a value securely in the local device's keychain associated with a specific key. This method is recommended for sensitive information. ```javascript tyme.setSecureValue(key, value) ``` -------------------------------- ### Setting Time Entry Billing State (Tyme API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Modifies the billing state for a list of time entries identified by their unique IDs. The billingState parameter accepts 0 for unbilled, 1 for billed, and 2 for paid. ```javascript tyme.setBillingState(timeEntryIDs, billingState) ``` -------------------------------- ### Base64 Encoding String (Utils API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Encodes a given string into its Base64 representation. ```javascript utils.base64Encode(string) ``` -------------------------------- ### Accessing Tyme Plugin Form Values (JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/README.md Demonstrates how to access the values entered by the user in the plugin form elements from within the plugin's JavaScript script using the global `formValue` object and the element's unique ID. ```JavaScript // access a form value formValue.someUniqueID; ``` -------------------------------- ### Checking File Existence (Utils API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Checks if a file exists within the plugin's sandboxed folder. File access is strictly limited to this directory. ```javascript utils.fileExists(fileName) ``` -------------------------------- ### Localizing String (Utils API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Returns the localized string for a given identifier, based on the user's language settings in Tyme. ```javascript utils.localize(string) ``` -------------------------------- ### Tyme Plugin FormElement Class (JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/README.md Shows the structure of the `FormElement` class, which represents a rendered form element in the Tyme UI. It exposes properties like `isHidden` and `enabled` for controlling visibility and interactivity, and a `reload()` method for refreshing dropdown contents (requires Tyme 2024.14+). ```JavaScript class FormElement { isHidden // bool enabled // bool reload() // Calls the valueFunction of a dropdown to reload it. Tyme 2024.14 needed } ``` -------------------------------- ### Base64 Decoding String (Utils API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Decodes a Base64 encoded string back into its original string format. ```javascript utils.base64Decode(string) ``` -------------------------------- ### Defining Tyme Plugin Form Action Function (JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/README.md Illustrates how to define a JavaScript function (`billableCheckboxClicked`) that is called automatically when the value of a form element with an `actionFunction` property changes. This allows for dynamic behavior in the form, such as enabling/disabling other elements based on user input. ```JavaScript // call an action, if the value of a form element changes billableCheckboxClicked() { formElement.markAsBilled.enabled = !formValue.onlyBillable; } ``` -------------------------------- ### Logging Debug Message (Utils API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Writes a message to the Tyme debug log. This log can be enabled in Tyme Preferences > Developer > Debug Log. ```javascript utils.log(string) ``` -------------------------------- ### Fetching User ID by Email (Tyme API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Attempts to retrieve the unique user ID for a team user based on their email address. ```javascript tyme.userIDForEmail(email) ``` -------------------------------- ### Removing File (Utils API, JavaScript) Source: https://github.com/tyme-app/plugins/blob/main/guides/scripting_helpers.md Deletes a file within the plugin's sandboxed folder. File access is strictly limited to this directory. ```javascript utils.removeFile(fileName) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.