Files
dub-node/codeSamples.yaml
2024-06-24 12:55:28 +05:30

541 lines
13 KiB
YAML

overlay: 1.0.0
info:
title: CodeSamples overlay for typescript target
version: 0.0.0
actions:
- target: $["paths"]["/workspaces/{idOrSlug}"]["get"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "getWorkspace"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.workspaces.get({
idOrSlug: "<value>",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/domains"]["get"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "listDomains"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.domains.list({});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/domains/{slug}"]["patch"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "updateDomain"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.domains.update("acme.com", {});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/track/sale"]["post"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "trackSale"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.track.sale({
customerId: "<value>",
amount: 996500,
paymentProcessor: "shopify",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/metatags"]["get"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "getMetatags"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.metatags.get({
url: "https://dub.co",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/links/{linkId}"]["patch"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "updateLink"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.links.update("<value>", {
url: "https://google/com",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/analytics"]["get"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "retrieveAnalytics"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.analytics.retrieve({});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/tags"]["post"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "createTag"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.tags.create({
tag: "<value>",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/domains/{slug}/primary"]["post"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "setPrimaryDomain"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.domains.setPrimary("acme.com");
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/track/lead"]["post"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "trackLead"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.track.lead({
clickId: "<value>",
eventName: "Sign up",
customerId: "<value>",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/qr"]["get"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "getQRCode"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.qrCodes.get({
url: "https://brief-micronutrient.org",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/links/upsert"]["put"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "upsertLink"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.links.upsert({
url: "https://google/com",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/links"]["get"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "getLinks"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.links.list({});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/links/info"]["get"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "getLinkInfo"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.links.get({});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/workspaces"]["get"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "getWorkspaces"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.workspaces.list();
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/tags"]["get"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "getTags"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.tags.list({});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/domains"]["post"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "createDomain"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.domains.create({
slug: "acme.com",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/domains/{slug}/transfer"]["post"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "transferDomain"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.domains.transfer("acme.com", {
newWorkspaceId: "<value>",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/links"]["post"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "createLink"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.links.create({
url: "https://google/com",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/links/{linkId}"]["delete"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "deleteLink"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.links.delete("<value>");
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/links/bulk"]["post"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "bulkCreateLinks"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.links.createMany([
{
url: "https://google/com",
},
]);
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/workspaces"]["post"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "createWorkspace"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.workspaces.create({
name: "<value>",
slug: "<value>",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/domains/{slug}"]["delete"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "deleteDomain"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.domains.delete("acme.com");
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/track/customer"]["post"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "trackCustomer"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.track.customer({
customerId: "<value>",
});
// Handle the result
console.log(result)
}
run();
- target: $["paths"]["/links/count"]["get"]
update:
"x-codeSamples":
- "lang": "typescript"
"label": "getLinksCount"
"source": |-
import { Dub } from "dub";
const dub = new Dub({
token: "DUB_API_KEY",
});
async function run() {
const result = await dub.links.count({});
// Handle the result
console.log(result)
}
run();