### Build and Run Example Source: https://github.com/dubinc/dub-ts/blob/main/examples/README.md Build the project and then run a TypeScript example file using tsx. ```bash npm run build && npx tsx example.ts ``` -------------------------------- ### CreatePartnerFieldsOptions Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/createpartnerfieldsoptions.md Example of how to create an instance of CreatePartnerFieldsOptions. Both label and value fields are required. ```typescript import { CreatePartnerFieldsOptions } from "dub/models/operations"; let value: CreatePartnerFieldsOptions = { label: "", value: "", }; ``` -------------------------------- ### CreatePartnerFieldsPartnersOptions Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/createpartnerfieldspartnersoptions.md Example of how to instantiate CreatePartnerFieldsPartnersOptions with required fields. Ensure to replace placeholder values. ```typescript import { CreatePartnerFieldsPartnersOptions } from "dub/models/operations"; let value: CreatePartnerFieldsPartnersOptions = { label: "", value: "", }; ``` -------------------------------- ### SDK Installation Source: https://github.com/dubinc/dub-ts/blob/main/README.md Instructions for installing the Dub.co TypeScript SDK using various package managers. ```APIDOC ## SDK Installation The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers. ### NPM ```bash npm add dub ``` ### PNPM ```bash pnpm add dub ``` ### Bun ```bash bun add dub ``` ### Yarn ```bash yarn add dub ``` > [!NOTE] > This package is published with CommonJS and ES Modules (ESM) support. ``` -------------------------------- ### Install Dub TypeScript SDK Source: https://context7.com/dubinc/dub-ts/llms.txt Install the Dub SDK using your preferred package manager. ```bash npm add dub # or pnpm add dub # or bun add dub # or yarn add dub ``` -------------------------------- ### SDK Example Usage Source: https://github.com/dubinc/dub-ts/blob/main/README.md Examples demonstrating how to initialize the Dub.co TypeScript SDK and perform basic operations like creating or upserting links. ```APIDOC ## SDK Example Usage ### Example 1 ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.links.create(); console.log(result); } run(); ``` ### Example 2 ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.links.upsert(); console.log(result); } run(); ``` ``` -------------------------------- ### Install Dub TypeScript SDK with Bun Source: https://github.com/dubinc/dub-ts/blob/main/README.md Install the Dub TypeScript SDK using the bun package manager. ```bash bun add dub ``` -------------------------------- ### Fields1 Example Usage Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/fields1.md Provides a TypeScript example demonstrating how to import and use the Fields1 model. ```APIDOC ## Example Usage ### Description This section shows a practical example of how to instantiate and use the `Fields1` model in TypeScript. ### Method N/A (This is a model definition, not an API endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example ```typescript import { Fields1 } from "dub/models/components"; let value: Fields1 = { key: "", label: "", required: false, locked: true, position: 547268, type: "text", }; ``` ### Response N/A ``` -------------------------------- ### PartnerApplicationSubmittedEventPartner Model Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/partnerapplicationsubmittedeventpartner.md This example demonstrates how to import and instantiate the PartnerApplicationSubmittedEventPartner model. Ensure the 'dub/models/components' path is correctly configured in your project. ```typescript import { PartnerApplicationSubmittedEventPartner } from "dub/models/components"; let value: PartnerApplicationSubmittedEventPartner = { id: "", name: "", companyName: "Medhurst, Luettgen and Kunze", email: "Bernard.OConner48@yahoo.com", image: "https://picsum.photos/seed/mq7Kf07DDk/752/1733", country: "Western Sahara", status: "rejected", }; ``` -------------------------------- ### TrackLeadResponseBody Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/trackleadresponsebody.md Example of how to define and use the TrackLeadResponseBody in TypeScript. Ensure all required fields are populated. ```typescript import { TrackLeadResponseBody } from "dub/models/operations"; let value: TrackLeadResponseBody = { click: { id: "", }, link: { id: "", domain: "ignorant-outrun.info", key: "", shortLink: "https://normal-innovation.org", url: "https://spirited-chow.com/", partnerId: "", programId: "", tenantId: "", externalId: "", }, customer: { name: "", email: "Emmy8@hotmail.com", avatar: "https://loremflickr.com/2520/643?lock=1623178356501000", externalId: "", }, }; ``` -------------------------------- ### Install Dub TypeScript SDK with PNPM Source: https://github.com/dubinc/dub-ts/blob/main/README.md Install the Dub TypeScript SDK using the pnpm package manager. ```bash pnpm add dub ``` -------------------------------- ### TrackSaleCustomer Model Usage Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/tracksalecustomer.md Demonstrates how to import and instantiate the TrackSaleCustomer model with example data. ```APIDOC ## TrackSaleCustomer Model ### Description Represents a customer record for tracking sales. ### Fields #### Request Body Fields - **id** (string) - Required - Unique identifier for the customer. - **name** (string) - Required - The name of the customer. - **email** (string) - Required - The email address of the customer. - **avatar** (string) - Required - URL to the customer's avatar image. - **externalId** (string) - Required - An external identifier for the customer. ### Request Example ```json { "id": "", "name": null, "email": "Kenny_Dare@yahoo.com", "avatar": null, "externalId": "" } ``` ``` -------------------------------- ### Select Field Example - components.Fields3 Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/fields.md Example of a select field configuration with options. Use for dropdown selections. ```typescript const value: components.Fields3 = { key: "", label: "", required: false, locked: true, position: 316855, type: "select", options: [ { label: "", value: "", }, ], }; ``` -------------------------------- ### Install Dub TypeScript SDK with NPM Source: https://github.com/dubinc/dub-ts/blob/main/README.md Install the Dub TypeScript SDK using the npm package manager. ```bash npm add dub ``` -------------------------------- ### Install Dub TypeScript SDK with Yarn Source: https://github.com/dubinc/dub-ts/blob/main/README.md Install the Dub TypeScript SDK using the yarn package manager. ```bash yarn add dub ``` -------------------------------- ### Link Model Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/link.md Example of how to define a Link object with all its properties. Ensure all placeholder values like '' and '' are replaced with actual data. ```typescript import { Link } from "dub/models/components"; let value: Link = { id: "", domain: "internal-farmer.biz", key: "", url: "https://excitable-decision.com", trackConversion: true, externalId: "", tenantId: "", programId: "", partnerId: "", archived: false, expiresAt: "1748136253288", expiredUrl: "https://yearly-leading.net/", disabledAt: "", password: "WJhIc4meWW4PIPI", proxy: true, title: "", description: "bravely refer probate calmly pfft apropos", image: "https://loremflickr.com/692/3497?lock=7330937860878962", video: "https://picsum.videos/seed/2WxHE8W0C/1296/2531", rewrite: false, doIndex: true, ios: "", android: "", geo: { "key": "https://speedy-recovery.com/", "key1": "https://acceptable-promise.name", "key2": "https://acidic-travel.net", }, publicStats: false, tags: [ { id: "", name: "", color: "purple", }, ], folderId: null, webhookIds: [ "", "", "", ], comments: "peninsula muddy insist supposing ew fast apud intently searchingly ew now why object inasmuch heating", shortLink: "https://lanky-soybean.info/", qrCode: "https://dead-bonfire.org/", utmSource: "", utmMedium: "", utmCampaign: null, utmTerm: "", utmContent: null, testStartedAt: "", testCompletedAt: "", userId: "", workspaceId: "", lastClicked: "", createdAt: "1706713581495", updatedAt: "1735622791386", tagId: "", projectId: "", }; ``` -------------------------------- ### Instantiate ListPartnersResponseBody Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/listpartnersresponsebody.md Example of how to instantiate the ListPartnersResponseBody model. Ensure all required fields are populated. ```typescript import { ListPartnersResponseBody } from "dub/models/operations"; let value: ListPartnersResponseBody = { id: "", name: "", companyName: "Price, Farrell and Huels", email: "Bertram77@gmail.com", image: "https://loremflickr.com/1081/3725?lock=8621276044447622", country: "New Zealand", defaultPayoutMethod: "stablecoin", paypalEmail: "", stripeConnectId: "", payoutsEnabledAt: "", trustedAt: "", programId: "", partnerId: "", tenantId: "", createdAt: "1722907712371", status: "banned", links: [], }; ``` -------------------------------- ### Instantiate LeadCreatedEventData Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/leadcreatedeventdata.md Example of how to create an instance of LeadCreatedEventData. Ensure all required fields are populated. ```typescript import { LeadCreatedEventData } from "dub/models/components"; let value: LeadCreatedEventData = { eventName: "", customer: { id: "", name: "", externalId: "", createdAt: "1718158709687", }, click: { id: "", timestamp: "", url: "https://optimistic-collectivization.org", country: "Trinidad and Tobago", city: "St. George", region: "", continent: "Antarctica", device: "Desktop", browser: "Safari", os: "Windows Phone", referer: "parallel-violin.biz", refererUrl: "https://appropriate-worth.biz/", qr: true, ip: "95.252.90.235", }, link: { id: "", domain: "standard-wilderness.net", key: "", url: "https://tense-kiss.org/", trackConversion: false, externalId: "", tenantId: "", programId: "", partnerId: "", archived: false, expiresAt: "1763119226400", expiredUrl: "https://shimmering-traditionalism.biz/", disabledAt: "", password: null, proxy: false, title: null, description: "now lox meaty unhealthy volunteer prestigious liberalize heavily abandoned", image: "https://picsum.photos/seed/QnsdiB/591/3815", video: "https://loremflickr.com/3825/426?lock=3694907848251566", rewrite: false, doIndex: false, ios: "", android: "", geo: {}, publicStats: true, tags: [ { id: "", name: "", color: "purple", }, ], folderId: "", webhookIds: [ "", ], comments: null, shortLink: "https://nocturnal-lady.info", qrCode: "https://aware-ad.org", utmSource: "", utmMedium: "", utmCampaign: "", utmTerm: "", utmContent: "", testStartedAt: "", testCompletedAt: "", userId: "", workspaceId: "", lastClicked: "", createdAt: "1718277940029", updatedAt: "1735669799346", tagId: "", projectId: "", }, metadata: { "key": "", "key1": "", "key2": "", }, }; ``` -------------------------------- ### Instantiate CreatePartnerFields4 Model Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/createpartnerfields4.md Example of how to create an instance of the CreatePartnerFields4 model with all its fields. ```typescript import { CreatePartnerFields4 } from "dub/models/operations"; let value: CreatePartnerFields4 = { key: "", label: "", required: false, locked: true, position: 261727, type: "country", }; ``` -------------------------------- ### Create a Customer object Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/customer.md Example of creating a Customer object with required fields. ```typescript import { Customer } from "dub/models/components"; let value: Customer = { id: "", name: "", externalId: "", createdAt: "1730600624183", }; ``` -------------------------------- ### Initialize AnalyticsRefererUrls Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/analyticsrefererurls.md Example of how to initialize an AnalyticsRefererUrls object. The refererUrl field is required. ```typescript import { AnalyticsRefererUrls } from "dub/models/components"; let value: AnalyticsRefererUrls = { refererUrl: "https://unlucky-sesame.info/", }; ``` -------------------------------- ### Instantiate SaleCreatedEventCustomer Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/salecreatedeventcustomer.md Example of how to instantiate the SaleCreatedEventCustomer model. Ensure all required fields are populated. ```typescript import { SaleCreatedEventCustomer } from "dub/models/components"; let value: SaleCreatedEventCustomer = { id: "", name: "", externalId: "", createdAt: "1708236066704", }; ``` -------------------------------- ### Initialize DeactivatePartnerRequestBody Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/deactivatepartnerrequestbody.md Example of how to import and initialize an empty DeactivatePartnerRequestBody object. Ensure the 'dub/models/operations' path is correct for your project setup. ```typescript import { DeactivatePartnerRequestBody } from "dub/models/operations"; let value: DeactivatePartnerRequestBody = {}; ``` -------------------------------- ### Initialize BulkUpdateLinksRequestBody Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/bulkupdatelinksrequestbody.md Example of how to import and initialize a BulkUpdateLinksRequestBody object in TypeScript. Ensure the 'dub/models/operations' path is correct for your project setup. ```typescript import { BulkUpdateLinksRequestBody } from "dub/models/operations"; let value: BulkUpdateLinksRequestBody = { data: {}, }; ``` -------------------------------- ### Instantiate Fields8 Model in TypeScript Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/fields8.md Example of how to import and create an instance of the Fields8 model. Ensure the 'dub/models/operations' path is correct for your project setup. ```typescript import { Fields8 } from "dub/models/operations"; let value: Fields8 = { key: "", label: "", required: false, locked: false, position: 809669, type: "phone", }; ``` -------------------------------- ### Instantiate Application Model Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/application.md Example of how to create an instance of the Application model, including fields for rejection details and review status. Ensure all required fields are populated. ```typescript import { Application } from "dub/models/components"; let value: Application = { rejectionReason: "notTheRightFit", rejectionNote: "", reviewedAt: "", }; ``` -------------------------------- ### Example Usage in TypeScript Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/fields2.md Demonstrates how to import and use the Fields2 model in a TypeScript application. ```APIDOC ## Example Usage ### Description This section provides a TypeScript code example illustrating how to import and instantiate the `Fields2` model. ### Method N/A (This is a model definition, not an API endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example ```typescript import { Fields2 } from "dub/models/operations"; let value: Fields2 = { key: "", label: "", required: false, locked: true, position: 352683, type: "textarea", }; ``` ### Response N/A ``` -------------------------------- ### FolderSchema Example Usage Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/folderschema.md Demonstrates how to create an instance of the FolderSchema with sample data. Ensure all required fields are populated. ```typescript import { FolderSchema } from "dub/models/components"; let value: FolderSchema = { id: "", name: "", description: "flustered dramatic bright variable hydrolyse relieve as bend", type: "mega", createdAt: "1710159476719", updatedAt: "1735623576792", }; ``` -------------------------------- ### Get Link Info with Standalone Function Source: https://github.com/dubinc/dub-ts/blob/main/docs/sdks/links/README.md This example demonstrates using the standalone `linksGet` function for retrieving link information, optimized for tree-shaking. It requires initializing `DubCore` and handles potential errors. ```typescript import { DubCore } from "dub/core.js"; import { linksGet } from "dub/funcs/linksGet.js"; // Use `DubCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const dub = new DubCore({ token: "DUB_API_KEY", }); async function run() { const res = await linksGet(dub); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("linksGet failed:", res.error); } } run(); ``` -------------------------------- ### LeadCreatedEvent Example Usage Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/leadcreatedevent.md An example of how to use the LeadCreatedEvent in TypeScript. ```APIDOC ## Example Usage ```typescript import { LeadCreatedEvent } from "dub/models/components"; let value: LeadCreatedEvent = { id: "", event: "lead.created", createdAt: "1731666610174", data: { eventName: "", customer: { id: "", name: "", externalId: "", createdAt: "1718158709687", }, click: { id: "", timestamp: "", url: "https://optimistic-collectivization.org", country: "Trinidad and Tobago", city: "St. George", region: "", continent: "Antarctica", device: "Desktop", browser: "Safari", os: "Windows Phone", referer: "parallel-violin.biz", refererUrl: "https://appropriate-worth.biz/", qr: true, ip: "95.252.90.235", }, link: { id: "", domain: "standard-wilderness.net", key: "", url: "https://tense-kiss.org/", trackConversion: false, externalId: "", tenantId: "", programId: "", partnerId: "", archived: false, expiresAt: "1763119226400", expiredUrl: "https://shimmering-traditionalism.biz/", disabledAt: "", password: null, proxy: false, title: null, description: "now lox meaty unhealthy volunteer prestigious liberalize heavily abandoned", image: "https://picsum.photos/seed/QnsdiB/591/3815", video: "https://loremflickr.com/3825/426?lock=3694907848251566", rewrite: false, doIndex: false, ios: "", android: "", geo: {}, publicStats: true, tags: [ { id: "", name: "", color: "purple", }, ], folderId: "", webhookIds: [ "", ], comments: null, shortLink: "https://nocturnal-lady.info", qrCode: "https://aware-ad.org", utmSource: "", utmMedium: "", utmCampaign: "", utmTerm: "", utmContent: "", testStartedAt: "", testCompletedAt: "", userId: "", workspaceId: "", lastClicked: "", createdAt: "1718277940029", updatedAt: "1735669799346", tagId: "", projectId: "", }, metadata: { "key": "", }, }, }; ``` ``` -------------------------------- ### Initialize Security Model Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/security.md Example of initializing the Security model with an API key. Ensure the token is correctly formatted. ```typescript import { Security } from "dub/models/components"; let value: Security = { token: "DUB_API_KEY", }; ``` -------------------------------- ### LinkSchema Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/responsebody.md Represents a successful link object. Ensure all required fields are populated. ```typescript const value: components.LinkSchema = { id: "", domain: "young-ecliptic.com", key: "", url: "https://ripe-inspection.biz", externalId: "", tenantId: "", programId: "", partnerId: "", expiresAt: "1757088512193", expiredUrl: "https://distant-disconnection.net", disabledAt: "", password: "fFjqWxmJUgFKF7t", title: null, description: "aha likewise until versus potentially cricket rust blushing memorise urgently", image: "https://picsum.photos/seed/G9Jvsmb/1005/1445", video: "https://loremflickr.com/1893/1546?lock=6200467992750340", ios: "", android: "", geo: { "key": "https://petty-approach.com/", "key1": "https://immediate-hundred.name/", "key2": "https://well-groomed-piglet.info/", }, tags: [ { id: "", name: "", color: "blue", }, ], folderId: "", webhookIds: [ "", ], comments: "enthusiastically ridge since near litter clamp hm really past since quietly although kettledrum since passionate", shortLink: "https://quick-labourer.net", qrCode: "https://fake-hello.com", utmSource: "", utmMedium: "", utmCampaign: "", utmTerm: "", utmContent: "", userId: "", workspaceId: "", lastClicked: "", createdAt: "1721445095637", updatedAt: "1735628606324", tagId: "", projectId: "", }; ``` -------------------------------- ### Fields5 TypeScript Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/fields5.md An example demonstrating how to use the Fields5 model in TypeScript. ```APIDOC ## TypeScript Example for Fields5 ### Description This example shows how to import and instantiate the Fields5 model in a TypeScript project. ### Method N/A (This is a model definition example) ### Endpoint N/A ### Parameters N/A ### Request Example ```typescript import { Fields5 } from "dub/models/operations"; let value: Fields5 = { key: "", label: "", required: false, locked: true, position: 749989, type: "date", }; ``` ### Response N/A ``` -------------------------------- ### Example Test Variants Configuration Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/linkschema.md Illustrates the structure for configuring A/B test variants, specifying URLs and traffic percentages. Ensure percentages sum to 100 for proper distribution. ```json { "url": "https://example.com/variant-1", "percentage": 50 } ``` ```json { "url": "https://example.com/variant-2", "percentage": 50 } ``` -------------------------------- ### Create RegisteredDomain Object Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/registereddomain.md Example of how to create a RegisteredDomain object. Ensure all required fields are provided. ```typescript import { RegisteredDomain } from "dub/models/components"; let value: RegisteredDomain = { id: "", autoRenewalDisabledAt: "", createdAt: "1712810186636", expiresAt: "1765280780027", renewalFee: 7443.9, }; ``` -------------------------------- ### Instantiate Application Model Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/application.md Example of how to create an instance of the Application model in TypeScript. Ensure necessary imports are included. ```typescript import { Application } from "dub/models/operations"; let value: Application = { rejectionReason: "notTheRightFit", rejectionNote: "", reviewedAt: "", }; ``` -------------------------------- ### GetCustomerDiscount Model Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/getcustomerdiscount.md Example of how to define a GetCustomerDiscount object. Ensure all required fields are populated. ```typescript import { GetCustomerDiscount } from "dub/models/operations"; let value: GetCustomerDiscount = { id: "", amount: 8336.01, type: "flat", maxDuration: 954.69, couponId: null, couponTestId: "", }; ``` -------------------------------- ### CreatePartnerResponseBody Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/createpartnerresponsebody.md Example of how to define a CreatePartnerResponseBody object. Ensure all required fields are populated correctly. ```typescript import { CreatePartnerResponseBody } from "dub/models/operations"; let value: CreatePartnerResponseBody = { id: "", name: "", companyName: "Bradtke - Stark", email: "Shawna_Nitzsche86@yahoo.com", image: "https://picsum.photos/seed/upt4d5D/663/567", country: "United States Minor Outlying Islands", defaultPayoutMethod: "paypal", paypalEmail: null, stripeConnectId: "", payoutsEnabledAt: "", trustedAt: "", programId: "", partnerId: "", tenantId: "", createdAt: "1721740577292", status: "banned", links: null, }; ``` -------------------------------- ### Example A/B Test Variants Configuration Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/listeventsresponsebodylink.md Illustrates the structure for configuring A/B test variants, specifying the URL and traffic percentage for each variant. Ensure the sum of percentages equals 100%. ```json { "url": "https://example.com/variant-1", "percentage": 50 }, { "url": "https://example.com/variant-2", "percentage": 50 } ``` -------------------------------- ### CreateReferralsEmbedTokenTestVariants Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/createreferralsembedtokentestvariants.md Example of how to define a CreateReferralsEmbedTokenTestVariants object. Ensure the 'url' and 'percentage' fields are provided. ```typescript import { CreateReferralsEmbedTokenTestVariants } from "dub/models/operations"; let value: CreateReferralsEmbedTokenTestVariants = { url: "https://superb-parade.biz/", percentage: 1120.16, }; ``` -------------------------------- ### CreateReferralsEmbedTokenResponseBody Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/createreferralsembedtokenresponsebody.md Example of how to create a CreateReferralsEmbedTokenResponseBody object in TypeScript. Ensure you have the 'dub/models/operations' module imported. ```typescript import { CreateReferralsEmbedTokenResponseBody } from "dub/models/operations"; let value: CreateReferralsEmbedTokenResponseBody = { publicToken: "", expires: "", }; ``` -------------------------------- ### Initialize Eight Model Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/eight.md Demonstrates how to import and initialize the Eight model with sample data. Ensure the 'dub/models/components' path is correctly configured. ```typescript import { Eight } from "dub/models/components"; let value: Eight = { key: "", label: "", required: false, locked: true, position: 193041, type: "phone", }; ``` -------------------------------- ### CreateFolderRequestBody Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/createfolderrequestbody.md Example of how to create a CreateFolderRequestBody object in TypeScript. Ensure you import the type from 'dub/models/operations'. ```typescript import { CreateFolderRequestBody } from "dub/models/operations"; let value: CreateFolderRequestBody = { name: "", }; ``` -------------------------------- ### ApproveBountySubmissionFiles Model Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/approvebountysubmissionfiles.md Example usage of the ApproveBountySubmissionFiles model. Ensure the 'dub/models/operations' module is imported. ```typescript import { ApproveBountySubmissionFiles } from "dub/models/operations"; let value: ApproveBountySubmissionFiles = { url: "https://fantastic-airman.net", fileName: "example.file", size: 1459.83, }; ``` -------------------------------- ### Instantiate Five Model Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/five.md Import and instantiate the Five model with example field values. Ensure all required fields are populated according to the model's schema. ```typescript import { Five } from "dub/models/operations"; let value: Five = { key: "", label: "", required: false, locked: false, position: 609230, type: "date", }; ``` -------------------------------- ### Number Field Example - components.Seven Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/fields.md Example of a number field configuration. Use for numeric input. ```typescript const value: components.Seven = { key: "", label: "", required: false, locked: true, position: 196549, type: "number", }; ``` -------------------------------- ### Create Partner Request Body Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/createpartnerrequestbody.md Demonstrates how to instantiate the CreatePartnerRequestBody with an email address. Ensure the 'dub/models/operations' path is correctly imported. ```typescript import { CreatePartnerRequestBody } from "dub/models/operations"; let value: CreatePartnerRequestBody = { email: "Arnoldo78@gmail.com", }; ``` -------------------------------- ### Date Field Example - components.Five Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/fields.md Example of a date field configuration. Use for date input. ```typescript const value: components.Five = { key: "", label: "", required: false, locked: false, position: 609230, type: "date", }; ``` -------------------------------- ### Instantiate TrackSaleCustomer Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/tracksalecustomer.md Example of how to create an instance of the TrackSaleCustomer model. Ensure all required fields are provided. ```typescript import { TrackSaleCustomer } from "dub/models/operations"; let value: TrackSaleCustomer = { id: "", name: null, email: "Kenny_Dare@yahoo.com", avatar: null, externalId: "", }; ``` -------------------------------- ### Country Field Example - components.Four Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/fields.md Example of a country field configuration. Use for selecting a country. ```typescript const value: components.Four = { key: "", label: "", required: true, locked: true, position: 731478, type: "country", }; ``` -------------------------------- ### Create a Sale Object in TypeScript Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/sale.md Example of how to create and initialize a Sale object in TypeScript. Ensure all required fields are provided. ```typescript import { Sale } from "dub/models/operations"; let value: Sale = { amount: 283.67, currency: "South Sudanese pound", paymentProcessor: "", invoiceId: "", metadata: { "key": "", }, }; ``` -------------------------------- ### CommissionCreatedEventData Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/commissioncreatedeventdata.md An example of how to instantiate the CommissionCreatedEventData object. Ensure all required fields are populated correctly. ```typescript import { CommissionCreatedEventData } from "dub/models/components"; let value: CommissionCreatedEventData = { id: "cm_1JVR7XRCSR0EDBAF39FZ4PMYE", amount: 28.03, earnings: 9813.81, currency: "Rand", status: "pending", invoiceId: "", description: "freckle safeguard only gosh bah failing optimistically if at well-to-do", quantity: 912.88, createdAt: "1721181340774", updatedAt: "1735684304094", partner: { id: "", name: "", email: "Tanner_Goodwin36@yahoo.com", image: "https://loremflickr.com/887/2527?lock=8475978227242498", payoutsEnabledAt: "", country: "Vanuatu", totalClicks: 4338.81, totalLeads: 9031.25, totalConversions: 7982.05, totalSales: 4176.67, totalSaleAmount: 6883.26, totalCommissions: 6180.26, }, link: null, }; ``` -------------------------------- ### Example Usage of Fields1 in TypeScript Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/fields1.md Demonstrates how to import and instantiate the Fields1 model in TypeScript. Ensure the 'dub/models/components' path is correctly configured. ```typescript import { Fields1 } from "dub/models/components"; let value: Fields1 = { key: "", label: "", required: false, locked: true, position: 547268, type: "text", }; ``` -------------------------------- ### CommissionCreatedEvent Structure and Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/commissioncreatedevent.md This snippet shows the structure of the CommissionCreatedEvent and provides a TypeScript example of how to use it. ```APIDOC ## CommissionCreatedEvent Triggered when a commission is created for a partner. ### Fields | Field | Type | Required | Description | |---|---|---|---| | `id` | *string* | :heavy_check_mark: | N/A | | `event` | [components.CommissionCreatedEventEvent](../../models/components/commissioncreatedeventevent.md) | :heavy_check_mark: | N/A | | `createdAt` | *string* | :heavy_check_mark: | N/A | | `data` | [components.CommissionCreatedEventData](../../models/components/commissioncreatedeventdata.md) | :heavy_check_mark: | N/A | ### Request Example ```typescript import { CommissionCreatedEvent } from "dub/models/components"; let value: CommissionCreatedEvent = { id: "", event: "commission.created", createdAt: "1708661168082", data: { id: "cm_1JVR7XRCSR0EDBAF39FZ4PMYE", amount: 3818.04, earnings: 5362.14, currency: "Dobra", status: "pending", invoiceId: "", description: "in unearth whose notwithstanding store worse reboot very buzzing", quantity: 3318.84, createdAt: "1717922655598", updatedAt: "1735647472347", partner: { id: "", name: "", email: "Tanner_Goodwin36@yahoo.com", image: "https://loremflickr.com/887/2527?lock=8475978227242498", payoutsEnabledAt: "", country: "Vanuatu", totalClicks: 4338.81, totalLeads: 9031.25, totalConversions: 7982.05, totalSales: 4176.67, totalSaleAmount: 6883.26, totalCommissions: 6180.26, }, link: { id: "", shortLink: "https://infamous-boyfriend.net", domain: "bad-contractor.org", key: "", }, }, }; ``` ``` -------------------------------- ### Instantiate Fields3 Model Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/fields3.md Example of how to create an instance of the Fields3 model with various properties. Ensure all required fields are populated. ```typescript import { Fields3 } from "dub/models/operations"; let value: Fields3 = { key: "", label: "", required: false, locked: true, position: 316855, type: "select", options: [ { label: "", value: "", }, ], }; ``` -------------------------------- ### RegisterDomainResponseBody Example Usage Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/registerdomainresponsebody.md Example of how to use the RegisterDomainResponseBody in TypeScript. Ensure the 'dub/models/operations' path is correctly configured. ```typescript import { RegisterDomainResponseBody } from "dub/models/operations"; let value: RegisterDomainResponseBody = { domain: "noxious-lid.com", status: "", expiration: 1375.78, }; ``` -------------------------------- ### Copy .env.template to .env Source: https://github.com/dubinc/dub-ts/blob/main/examples/README.md Copy the template file to create your environment configuration. ```bash cp .env.template .env ``` -------------------------------- ### Phone Field Example - components.Eight Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/fields.md Example of a phone field configuration. Use for phone number input. ```typescript const value: components.Eight = { key: "", label: "", required: false, locked: true, position: 193041, type: "phone", }; ``` -------------------------------- ### Configure Custom HTTP Client Source: https://context7.com/dubinc/dub-ts/llms.txt Configure a custom HTTP client for proxies, timeouts, or custom headers. This example demonstrates setting up a custom fetcher and adding request hooks. ```typescript import { Dub } from "dub"; import { HTTPClient } from "dub/lib/http"; const httpClient = new HTTPClient({ fetcher: (input, init) => fetch(input, init), }); httpClient.addHook("beforeRequest", (request) => { const nextRequest = new Request(request, { signal: request.signal || AbortSignal.timeout(5000), }); nextRequest.headers.set("x-custom-header", "custom-value"); return nextRequest; }); httpClient.addHook("requestError", (error, request) => { console.error("Request failed:", error, request.url); }); const dub = new Dub({ token: "DUB_API_KEY", httpClient: httpClient, }); ``` -------------------------------- ### Instantiate Fields2 Model Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/fields2.md Example of how to create an instance of the Fields2 model with various properties. Ensure all required fields are populated. ```typescript import { Fields2 } from "dub/models/operations"; let value: Fields2 = { key: "", label: "", required: false, locked: true, position: 352683, type: "textarea", }; ``` -------------------------------- ### Fields2 TypeScript Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/fields2.md Example usage of the Fields2 model in TypeScript, demonstrating how to instantiate and populate the object. ```typescript import { Fields2 } from "dub/models/components"; let value: Fields2 = { key: "", label: "", required: false, locked: true, position: 352683, type: "textarea", }; ``` -------------------------------- ### Initialize AnalyticsOS Object Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/analyticsos.md Example of how to import and initialize an AnalyticsOS object with the OS field. ```typescript import { AnalyticsOS } from "dub/models/components"; let value: AnalyticsOS = { os: "Windows", }; ``` -------------------------------- ### Textarea Field Example - components.Fields2 Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/fields.md Example of a textarea field configuration. Use for multi-line text input. ```typescript const value: components.Fields2 = { key: "", label: "", required: false, locked: true, position: 352683, type: "textarea", }; ``` -------------------------------- ### Text Field Example - components.Fields1 Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/fields.md Example of a text field configuration. Use for single-line text input. ```typescript const value: components.Fields1 = { key: "", label: "", required: false, locked: true, position: 547268, type: "text", }; ``` -------------------------------- ### Import and Use CreatePartnerDefaultPayoutMethod Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/createpartnerdefaultpayoutmethod.md Import the CreatePartnerDefaultPayoutMethod type and assign a valid payout method value. Supported values are 'connect', 'stablecoin', and 'paypal'. ```typescript import { CreatePartnerDefaultPayoutMethod } from "dub/models/operations"; let value: CreatePartnerDefaultPayoutMethod = "connect"; ``` ```typescript "connect" | "stablecoin" | "paypal" ``` -------------------------------- ### Instantiate Six Model Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/six.md Example of how to create an instance of the Six model. Ensure all required fields are populated according to the model's schema. ```typescript import { Six } from "dub/models/operations"; let value: Six = { key: "", label: "", required: false, locked: true, position: 880951, type: "multiSelect", options: [], }; ``` -------------------------------- ### TrackSaleResponseBody Example Usage Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/tracksaleresponsebody.md Example of how to instantiate and use the TrackSaleResponseBody in TypeScript. Ensure the 'dub/models/operations' path is correctly configured. ```typescript import { TrackSaleResponseBody } from "dub/models/operations"; let value: TrackSaleResponseBody = { eventName: "", customer: null, sale: { amount: 321.43, currency: "Libyan Dinar", paymentProcessor: "", invoiceId: "", metadata: {}, }, }; ``` -------------------------------- ### Initialize Dub Client Source: https://context7.com/dubinc/dub-ts/llms.txt Initialize the Dub client with your API key to authenticate all requests. ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); ``` -------------------------------- ### Instantiate ListPayoutsResponseBody Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/listpayoutsresponsebody.md Example of how to instantiate the ListPayoutsResponseBody object. Ensure all required fields are populated correctly. ```typescript import { ListPayoutsResponseBody } from "dub/models/operations"; let value: ListPayoutsResponseBody = { id: "", invoiceId: "", amount: 4110.29, currency: "Brazilian Real", status: "canceled", periodStart: "", periodEnd: "", createdAt: "1704178992024", initiatedAt: "", paidAt: null, mode: null, method: "paypal", partner: { id: "", name: "", email: "Will_Cassin@hotmail.com", image: "https://picsum.photos/seed/YqHOiVtyX/1234/2214", defaultPayoutMethod: "connect", payoutsEnabledAt: "", country: "Libyan Arab Jamahiriya", tenantId: "", }, }; ``` -------------------------------- ### Initialize ListDomainsRequest Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/listdomainsrequest.md Demonstrates how to import and initialize an empty ListDomainsRequest object. All fields are optional. ```typescript import { ListDomainsRequest } from "dub/models/operations"; let value: ListDomainsRequest = {}; ``` -------------------------------- ### Multi-Select Field Example - components.Six Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/fields.md Example of a multi-select field configuration with options. Use for selecting multiple items from a list. ```typescript const value: components.Six = { key: "", label: "", required: false, locked: true, position: 880951, type: "multiSelect", options: [], }; ``` -------------------------------- ### Instantiate LinkTagSchema Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/linktagschema.md Example of how to create an instance of the LinkTagSchema. Ensure all required fields (id, name, color) are provided. ```typescript import { LinkTagSchema } from "dub/models/components"; let value: LinkTagSchema = { id: "", name: "", color: "yellow", }; ``` -------------------------------- ### Create Domain Request Body Example Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/operations/createdomainrequestbody.md Example of how to create a CreateDomainRequestBody object with a slug. Ensure the slug is a valid domain name. ```typescript import { CreateDomainRequestBody } from "dub/models/operations"; let value: CreateDomainRequestBody = { slug: "acme.com", }; ``` -------------------------------- ### Initialize Six Model Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/six.md Demonstrates how to import and define a Six model object with its properties. Ensure the 'dub/models/components' path is correct for your project setup. ```typescript import { Six } from "dub/models/components"; let value: Six = { key: "", label: "", required: false, locked: true, position: 880951, type: "multiSelect", options: [], }; ``` -------------------------------- ### Initialize PartnerAnalyticsTimeseries Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/partneranalyticstimeseries.md Import and initialize a PartnerAnalyticsTimeseries object. The 'start' field is a required string representing the interval's start timestamp. ```typescript import { PartnerAnalyticsTimeseries } from "dub/models/components"; let value: PartnerAnalyticsTimeseries = { start: "", }; ``` -------------------------------- ### Create DomainSchema Object Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/domainschema.md Example of creating a DomainSchema object with various properties including domain details, placeholder URLs, and registration information. Ensure all required fields are populated. ```typescript import { DomainSchema } from "dub/models/components"; let value: DomainSchema = { id: "", slug: "acme.com", placeholder: "https://dub.co/help/article/dub-links", expiredUrl: "https://acme.com/expired", notFoundUrl: "https://acme.com/not-found", logo: "", createdAt: "1729485621534", updatedAt: "1735617512405", registeredDomain: { id: "", autoRenewalDisabledAt: "", createdAt: "1728300349795", expiresAt: "1749848677535", renewalFee: 5772.53, }, }; ``` -------------------------------- ### Initialize AnalyticsDevices Model Source: https://github.com/dubinc/dub-ts/blob/main/docs/models/components/analyticsdevices.md Import and initialize the AnalyticsDevices model with a device name. Ensure the 'dub/models/components' path is correctly configured. ```typescript import { AnalyticsDevices } from "dub/models/components"; let value: AnalyticsDevices = { device: "Desktop", }; ```