Skip to content

Latest commit

 

History

History
177 lines (129 loc) · 17.5 KB

File metadata and controls

177 lines (129 loc) · 17.5 KB

Snippet

(snippet)

Overview

Methods related to Snippets

Available Operations

delete

Delete snippets

Example Usage

import { Writer } from "@writerai/writer-sdk";

const writer = new Writer({
  apiKey: "<YOUR_API_KEY_HERE>",
  organizationId: 545907,
});

async function run() {
  const teamId = 841399;
  const xRequestID = "<value>";
  const ids = [
    "<value>",
  ];
  const organizationId = 698486;
  
  const result = await writer.snippet.delete(teamId, xRequestID, ids, organizationId);

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
teamId number ✔️ N/A
xRequestID string N/A
ids string[] N/A
organizationId number N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.DeleteSnippetsResponse>

Errors

Error Object Status Code Content Type
errors.FailResponse 400,401,403,404,500 application/json
errors.SDKError 4xx-5xx /

find

Find snippets

Example Usage

import { Writer } from "@writerai/writer-sdk";

const writer = new Writer({
  apiKey: "<YOUR_API_KEY_HERE>",
  organizationId: 40141,
});

async function run() {
  const result = await writer.snippet.find({
    shortcuts: [
      "<value>",
    ],
    tags: [
      "<value>",
    ],
    teamId: 326883,
  });

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
request operations.FindSnippetsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.FindSnippetsResponse>

Errors

Error Object Status Code Content Type
errors.FailResponse 400,401,403,404,500 application/json
errors.SDKError 4xx-5xx /

update

Update snippets

Example Usage

import { Writer } from "@writerai/writer-sdk";

const writer = new Writer({
  apiKey: "<YOUR_API_KEY_HERE>",
  organizationId: 857478,
});

async function run() {
  const teamId = 24555;
  const requestBody = [
    {
      id: "<id>",
      snippet: "<value>",
      tags: [
        {
          tag: "<value>",
        },
      ],
    },
  ];
  const xRequestID = "<value>";
  const organizationId = 597129;
  
  const result = await writer.snippet.update(teamId, requestBody, xRequestID, organizationId);

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
teamId number ✔️ N/A
requestBody shared.SnippetUpdate[] N/A
xRequestID string N/A
organizationId number N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.

Response

Promise<operations.UpdateSnippetsResponse>

Errors

Error Object Status Code Content Type
errors.FailResponse 400,401,403,404,500 application/json
errors.SDKError 4xx-5xx /