← Public packages
@kentcdodds/kit
Kit.com helpers for subscribers, tags, forms, sequences, and broadcasts.
src/openapi-client.js
892 lines · 25.9 KB · JavaScript/**
* Scaffolded by Kody from an OpenAPI spec.
* Spec: Kit API v4.0
* Provider label: Kit
* Secret placeholders (e.g. {{secret:name}}) resolve via Kody's fetch gateway;
* host approval is enforced there and is never widened by this spec.
*
* Source: openapi_client_scaffold against
* https://developers.kit.com/api-reference/v4.json
* Auth: headerSecret kitApiKey → X-Kit-Api-Key
*/
const API_BASE_URL = "https://api.kit.com";
function buildUrl(pathTemplate, params = {}) {
return API_BASE_URL + pathTemplate.replace(/\{([^}]+)\}/g, (_match, name) => {
const value = params[name];
if (value === undefined || value === null) {
throw new Error(`Missing required path parameter: ${name}`);
}
return encodeURIComponent(String(value));
});
}
function appendQuery(url, query = {}) {
const search = new URLSearchParams();
for (const [key, value] of Object.entries(query)) {
if (value === undefined || value === null) continue;
if (Array.isArray(value)) {
for (const item of value) {
if (item === undefined || item === null) continue;
search.append(key, String(item));
}
continue;
}
search.append(key, String(value));
}
const qs = search.toString();
return qs ? `${url}?${qs}` : url;
}
function mergeHeaders(userHeaders, authHeaders) {
const merged = { ...(userHeaders ?? {}) };
for (const [key, value] of Object.entries(authHeaders)) {
// Auth headers always win; callers cannot override them.
const lower = key.toLowerCase();
for (const existing of Object.keys(merged)) {
if (existing.toLowerCase() === lower) {
delete merged[existing];
}
}
merged[key] = value;
}
return merged;
}
function hasHeader(headers, name) {
const lower = name.toLowerCase();
return Object.keys(headers).some((key) => key.toLowerCase() === lower);
}
async function resolveFetch(fetchImpl) {
return fetchImpl ?? fetch;
}
function authHeaders() {
return {
"X-Kit-Api-Key": "{{secret:kitApiKey}}"
};
}
/**
* GET /v4/account — Get current account
* Auth: headerSecret
*/
export async function getV4Account(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/account", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* GET /v4/account/email_stats — Get email stats
* Auth: headerSecret
*/
export async function getV4AccountEmailStats(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/account/email_stats", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* GET /v4/account/growth_stats — Get growth stats
* Auth: headerSecret
*/
export async function getV4AccountGrowthStats(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/account/growth_stats", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* GET /v4/broadcasts — List broadcasts
* Auth: headerSecret
*/
export async function getV4Broadcasts(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/broadcasts", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* POST /v4/broadcasts — Create a broadcast
* Auth: headerSecret
*/
export async function postV4Broadcasts(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/broadcasts", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "POST",
headers,
body,
});
}
/**
* GET /v4/broadcasts/{id} — Get a broadcast
* Auth: headerSecret
*/
export async function getV4BroadcastsId(input = {}, options = {}) {
const params = input.params ?? {};
if (params["id"] === undefined || params["id"] === null) {
throw new Error("Missing required path parameter: id");
}
const url = appendQuery(buildUrl("/v4/broadcasts/{id}", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* PUT /v4/broadcasts/{id} — Update a broadcast
* Auth: headerSecret
*/
export async function putV4BroadcastsId(input = {}, options = {}) {
const params = input.params ?? {};
if (params["id"] === undefined || params["id"] === null) {
throw new Error("Missing required path parameter: id");
}
const url = appendQuery(buildUrl("/v4/broadcasts/{id}", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "PUT",
headers,
body,
});
}
/**
* DELETE /v4/broadcasts/{id} — Delete a broadcast
* Auth: headerSecret
*/
export async function deleteV4BroadcastsId(input = {}, options = {}) {
const params = input.params ?? {};
if (params["id"] === undefined || params["id"] === null) {
throw new Error("Missing required path parameter: id");
}
const url = appendQuery(buildUrl("/v4/broadcasts/{id}", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "DELETE",
headers,
body,
});
}
/**
* GET /v4/broadcasts/{broadcast_id}/stats — Get stats for a broadcast
* Auth: headerSecret
*/
export async function getV4BroadcastsBroadcastIdStats(input = {}, options = {}) {
const params = input.params ?? {};
if (params["broadcast_id"] === undefined || params["broadcast_id"] === null) {
throw new Error("Missing required path parameter: broadcast_id");
}
const url = appendQuery(buildUrl("/v4/broadcasts/{broadcast_id}/stats", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* GET /v4/broadcasts/stats — Get stats for a list of broadcasts
* Auth: headerSecret
*/
export async function getV4BroadcastsStats(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/broadcasts/stats", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* GET /v4/subscribers — List subscribers
* Auth: headerSecret
*/
export async function getV4Subscribers(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/subscribers", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* POST /v4/subscribers — Create a subscriber
* Auth: headerSecret
*/
export async function postV4Subscribers(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/subscribers", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "POST",
headers,
body,
});
}
/**
* GET /v4/subscribers/{id} — Get a subscriber
* Auth: headerSecret
*/
export async function getV4SubscribersId(input = {}, options = {}) {
const params = input.params ?? {};
if (params["id"] === undefined || params["id"] === null) {
throw new Error("Missing required path parameter: id");
}
const url = appendQuery(buildUrl("/v4/subscribers/{id}", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* PUT /v4/subscribers/{id} — Update a subscriber
* Auth: headerSecret
*/
export async function putV4SubscribersId(input = {}, options = {}) {
const params = input.params ?? {};
if (params["id"] === undefined || params["id"] === null) {
throw new Error("Missing required path parameter: id");
}
const url = appendQuery(buildUrl("/v4/subscribers/{id}", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "PUT",
headers,
body,
});
}
/**
* POST /v4/subscribers/{id}/unsubscribe — Unsubscribe subscriber
* Auth: headerSecret
*/
export async function postV4SubscribersIdUnsubscribe(input = {}, options = {}) {
const params = input.params ?? {};
if (params["id"] === undefined || params["id"] === null) {
throw new Error("Missing required path parameter: id");
}
const url = appendQuery(buildUrl("/v4/subscribers/{id}/unsubscribe", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "POST",
headers,
body,
});
}
/**
* GET /v4/subscribers/{subscriber_id}/tags — List tags for a subscriber
* Auth: headerSecret
*/
export async function getV4SubscribersSubscriberIdTags(input = {}, options = {}) {
const params = input.params ?? {};
if (params["subscriber_id"] === undefined || params["subscriber_id"] === null) {
throw new Error("Missing required path parameter: subscriber_id");
}
const url = appendQuery(buildUrl("/v4/subscribers/{subscriber_id}/tags", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* GET /v4/tags — List tags
* Auth: headerSecret
*/
export async function getV4Tags(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/tags", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* POST /v4/tags — Create a tag
* Auth: headerSecret
*/
export async function postV4Tags(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/tags", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "POST",
headers,
body,
});
}
/**
* POST /v4/tags/{tag_id}/subscribers — Tag a subscriber by email address
* Auth: headerSecret
*/
export async function postV4TagsTagIdSubscribers(input = {}, options = {}) {
const params = input.params ?? {};
if (params["tag_id"] === undefined || params["tag_id"] === null) {
throw new Error("Missing required path parameter: tag_id");
}
const url = appendQuery(buildUrl("/v4/tags/{tag_id}/subscribers", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "POST",
headers,
body,
});
}
/**
* GET /v4/tags/{tag_id}/subscribers — List subscribers for a tag
* Auth: headerSecret
*/
export async function getV4TagsTagIdSubscribers(input = {}, options = {}) {
const params = input.params ?? {};
if (params["tag_id"] === undefined || params["tag_id"] === null) {
throw new Error("Missing required path parameter: tag_id");
}
const url = appendQuery(buildUrl("/v4/tags/{tag_id}/subscribers", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* DELETE /v4/tags/{tag_id}/subscribers/{id} — Remove tag from subscriber
* Auth: headerSecret
*/
export async function deleteV4TagsTagIdSubscribersId(input = {}, options = {}) {
const params = input.params ?? {};
if (params["id"] === undefined || params["id"] === null) {
throw new Error("Missing required path parameter: id");
}
if (params["tag_id"] === undefined || params["tag_id"] === null) {
throw new Error("Missing required path parameter: tag_id");
}
const url = appendQuery(buildUrl("/v4/tags/{tag_id}/subscribers/{id}", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "DELETE",
headers,
body,
});
}
/**
* DELETE /v4/bulk/tags — Bulk delete tags
* Auth: headerSecret
*/
export async function deleteV4BulkTags(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/bulk/tags", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "DELETE",
headers,
body,
});
}
/**
* GET /v4/forms — List forms
* Auth: headerSecret
*/
export async function getV4Forms(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/forms", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* POST /v4/forms/{form_id}/subscribers — Add subscriber to form by email address
* Auth: headerSecret
*/
export async function postV4FormsFormIdSubscribers(input = {}, options = {}) {
const params = input.params ?? {};
if (params["form_id"] === undefined || params["form_id"] === null) {
throw new Error("Missing required path parameter: form_id");
}
const url = appendQuery(buildUrl("/v4/forms/{form_id}/subscribers", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "POST",
headers,
body,
});
}
/**
* GET /v4/segments — List segments
* Auth: headerSecret
*/
export async function getV4Segments(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/segments", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* POST /v4/sequences — Create a sequence
* Auth: headerSecret
*/
export async function postV4Sequences(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/sequences", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "POST",
headers,
body,
});
}
/**
* POST /v4/sequences/{sequence_id}/emails — Create a sequence email
* Auth: headerSecret
*/
export async function postV4SequencesSequenceIdEmails(input = {}, options = {}) {
const params = input.params ?? {};
if (params["sequence_id"] === undefined || params["sequence_id"] === null) {
throw new Error("Missing required path parameter: sequence_id");
}
const url = appendQuery(buildUrl("/v4/sequences/{sequence_id}/emails", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "POST",
headers,
body,
});
}
/**
* POST /v4/sequences/{sequence_id}/subscribers — Add subscriber to sequence by email address
* Auth: headerSecret
*/
export async function postV4SequencesSequenceIdSubscribers(input = {}, options = {}) {
const params = input.params ?? {};
if (params["sequence_id"] === undefined || params["sequence_id"] === null) {
throw new Error("Missing required path parameter: sequence_id");
}
const url = appendQuery(buildUrl("/v4/sequences/{sequence_id}/subscribers", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "POST",
headers,
body,
});
}
/**
* GET /v4/sequences — List sequences
* Auth: headerSecret
*/
export async function getV4Sequences(input = {}, options = {}) {
const params = input.params ?? {};
const url = appendQuery(buildUrl("/v4/sequences", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* GET /v4/sequences/{id} — Get a sequence
* Auth: headerSecret
*/
export async function getV4SequencesId(input = {}, options = {}) {
const params = input.params ?? {};
if (params["id"] === undefined || params["id"] === null) {
throw new Error("Missing required path parameter: id");
}
const url = appendQuery(buildUrl("/v4/sequences/{id}", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* GET /v4/sequences/{sequence_id}/emails — List sequence emails
* Auth: headerSecret
*/
export async function getV4SequencesSequenceIdEmails(input = {}, options = {}) {
const params = input.params ?? {};
if (params["sequence_id"] === undefined || params["sequence_id"] === null) {
throw new Error("Missing required path parameter: sequence_id");
}
const url = appendQuery(buildUrl("/v4/sequences/{sequence_id}/emails", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* GET /v4/sequences/{sequence_id}/emails/{id} — Get a sequence email
* Auth: headerSecret
*/
export async function getV4SequencesSequenceIdEmailsId(input = {}, options = {}) {
const params = input.params ?? {};
if (params["id"] === undefined || params["id"] === null) {
throw new Error("Missing required path parameter: id");
}
if (params["sequence_id"] === undefined || params["sequence_id"] === null) {
throw new Error("Missing required path parameter: sequence_id");
}
const url = appendQuery(buildUrl("/v4/sequences/{sequence_id}/emails/{id}", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "GET",
headers,
body,
});
}
/**
* PUT /v4/sequences/{sequence_id}/emails/{id} — Update a sequence email
* Auth: headerSecret
*/
export async function putV4SequencesSequenceIdEmailsId(input = {}, options = {}) {
const params = input.params ?? {};
if (params["id"] === undefined || params["id"] === null) {
throw new Error("Missing required path parameter: id");
}
if (params["sequence_id"] === undefined || params["sequence_id"] === null) {
throw new Error("Missing required path parameter: sequence_id");
}
const url = appendQuery(buildUrl("/v4/sequences/{sequence_id}/emails/{id}", params), input.query);
let body = undefined;
const headers = mergeHeaders(input.headers, authHeaders());
if (input.body !== undefined) {
body = JSON.stringify(input.body);
if (!hasHeader(headers, "content-type")) {
headers["content-type"] = "application/json";
}
}
const fetchImpl = await resolveFetch(options.fetchImpl);
return fetchImpl(url, {
method: "PUT",
headers,
body,
});
}