/**
* Klaviyo API
* The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details.
*
* Contact: developers@klaviyo.com
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
const axios = require('axios');
import {AxiosRequestConfig, AxiosResponse} from "axios";
import FormData from 'form-data'
/* tslint:disable:no-unused-locals */
import { GetAccounts4XXResponse } from '../model/getAccounts4XXResponse';
import { GetWebFeedResponse } from '../model/getWebFeedResponse';
import { GetWebFeedResponseCollection } from '../model/getWebFeedResponseCollection';
import { PatchWebFeedResponse } from '../model/patchWebFeedResponse';
import { PostWebFeedResponse } from '../model/postWebFeedResponse';
import { WebFeedCreateQuery } from '../model/webFeedCreateQuery';
import { WebFeedPartialUpdateQuery } from '../model/webFeedPartialUpdateQuery';
import { ObjectSerializer } from '../model/models';
import {RequestFile, queryParamPreProcessor, RetryWithExponentialBackoff, Session} from './apis';
let defaultBasePath = 'https://a.klaviyo.com';
// ===============================================
// This file is autogenerated - Please do not edit
// ===============================================
export class WebFeedsApi {
session: Session
protected _basePath = defaultBasePath;
protected _defaultHeaders : any = {};
protected _useQuerystring : boolean = false;
constructor(session: Session){
this.session = session
}
set useQuerystring(value: boolean) {
this._useQuerystring = value;
}
set basePath(basePath: string) {
this._basePath = basePath;
}
set defaultHeaders(defaultHeaders: any) {
this._defaultHeaders = defaultHeaders;
}
get defaultHeaders() {
return this._defaultHeaders;
}
get basePath() {
return this._basePath;
}
/**
* Create a web feed.
*Rate limits*:
Burst: `1/s`
Steady: `15/m` **Scopes:** `web-feeds:write`
* @summary Create Web Feed
* @param webFeedCreateQuery Create a web feed
*/
public async createWebFeed (webFeedCreateQuery: WebFeedCreateQuery, ): Promise<{ response: AxiosResponse; body: PostWebFeedResponse; }> {
const localVarPath = this.basePath + '/api/web-feeds';
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders);
const produces = ['application/vnd.api+json'];
// give precedence to 'application/json'
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
} else {
localVarHeaderParams.Accept = produces.join(',');
}
// verify required parameter 'webFeedCreateQuery' is not null or undefined
if (webFeedCreateQuery === null || webFeedCreateQuery === undefined) {
throw new Error('Required parameter webFeedCreateQuery was null or undefined when calling createWebFeed.');
}
queryParamPreProcessor(localVarQueryParameters)
let config: AxiosRequestConfig = {
method: 'POST',
url: localVarPath,
headers: localVarHeaderParams,
params: localVarQueryParameters,
data: ObjectSerializer.serialize(webFeedCreateQuery, "WebFeedCreateQuery")
}
await this.session.applyToRequest(config)
const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PostWebFeedResponse; }> => {
try {
const axiosResponse = await this.session.requestWithRetry(config)
let body;
body = ObjectSerializer.deserialize(axiosResponse.data, "PostWebFeedResponse");
return ({response: axiosResponse, body: body});
} catch (error) {
if (await this.session.refreshAndRetry(error, retried)) {
await this.session.applyToRequest(config)
return request(config, true)
}
throw error
}
}
return request(config)
}
/**
* Delete the web feed with the given ID.
*Rate limits*:
Burst: `1/s`
Steady: `15/m` **Scopes:** `web-feeds:write`
* @summary Delete Web Feed
* @param id The ID of the web feed
*/
public async deleteWebFeed (id: string, ): Promise<{ response: AxiosResponse; body?: any; }> {
const localVarPath = this.basePath + '/api/web-feeds/{id}'
.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders);
const produces = ['application/vnd.api+json'];
// give precedence to 'application/json'
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
} else {
localVarHeaderParams.Accept = produces.join(',');
}
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling deleteWebFeed.');
}
queryParamPreProcessor(localVarQueryParameters)
let config: AxiosRequestConfig = {
method: 'DELETE',
url: localVarPath,
headers: localVarHeaderParams,
params: localVarQueryParameters,
}
await this.session.applyToRequest(config)
const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body?: any; }> => {
try {
const axiosResponse = await this.session.requestWithRetry(config)
let body;
return ({response: axiosResponse, body: body});
} catch (error) {
if (await this.session.refreshAndRetry(error, retried)) {
await this.session.applyToRequest(config)
return request(config, true)
}
throw error
}
}
return request(config)
}
/**
* Get the web feed with the given ID.
*Rate limits*:
Burst: `1/s`
Steady: `15/m` **Scopes:** `web-feeds:read`
* @summary Get Web Feed
* @param id The ID of the web feed
* @param fieldsWebFeed For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets
*/
public async getWebFeed (id: string, options: { fieldsWebFeed?: Array<'content_type' | 'created' | 'name' | 'request_method' | 'status' | 'updated' | 'url'>, } = {}): Promise<{ response: AxiosResponse; body: GetWebFeedResponse; }> {
const localVarPath = this.basePath + '/api/web-feeds/{id}'
.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders);
const produces = ['application/vnd.api+json'];
// give precedence to 'application/json'
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
} else {
localVarHeaderParams.Accept = produces.join(',');
}
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling getWebFeed.');
}
if (options.fieldsWebFeed !== undefined) {
localVarQueryParameters['fields[web-feed]'] = ObjectSerializer.serialize(options.fieldsWebFeed, "Array<'content_type' | 'created' | 'name' | 'request_method' | 'status' | 'updated' | 'url'>");
}
queryParamPreProcessor(localVarQueryParameters)
let config: AxiosRequestConfig = {
method: 'GET',
url: localVarPath,
headers: localVarHeaderParams,
params: localVarQueryParameters,
}
await this.session.applyToRequest(config)
const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetWebFeedResponse; }> => {
try {
const axiosResponse = await this.session.requestWithRetry(config)
let body;
body = ObjectSerializer.deserialize(axiosResponse.data, "GetWebFeedResponse");
return ({response: axiosResponse, body: body});
} catch (error) {
if (await this.session.refreshAndRetry(error, retried)) {
await this.session.applyToRequest(config)
return request(config, true)
}
throw error
}
}
return request(config)
}
/**
* Get all web feeds for an account.
*Rate limits*:
Burst: `1/s`
Steady: `15/m` **Scopes:** `web-feeds:read`
* @summary Get Web Feeds
* @param fieldsWebFeed For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param filter For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`name`: `any`, `contains`, `equals`<br>`created`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`<br>`updated`: `greater-or-equal`, `greater-than`, `less-or-equal`, `less-than`* @param pageCursor For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#pagination* @param pageSize Default: 5. Min: 1. Max: 20.* @param sort For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sorting
*/
public async getWebFeeds (options: { fieldsWebFeed?: Array<'content_type' | 'created' | 'name' | 'request_method' | 'status' | 'updated' | 'url'>, filter?: string, pageCursor?: string, pageSize?: number, sort?: 'created' | '-created' | 'name' | '-name' | 'updated' | '-updated', } = {}): Promise<{ response: AxiosResponse; body: GetWebFeedResponseCollection; }> {
const localVarPath = this.basePath + '/api/web-feeds';
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders);
const produces = ['application/vnd.api+json'];
// give precedence to 'application/json'
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
} else {
localVarHeaderParams.Accept = produces.join(',');
}
if (options.fieldsWebFeed !== undefined) {
localVarQueryParameters['fields[web-feed]'] = ObjectSerializer.serialize(options.fieldsWebFeed, "Array<'content_type' | 'created' | 'name' | 'request_method' | 'status' | 'updated' | 'url'>");
}
if (options.filter !== undefined) {
localVarQueryParameters['filter'] = ObjectSerializer.serialize(options.filter, "string");
}
if (options.pageCursor !== undefined) {
localVarQueryParameters['page[cursor]'] = ObjectSerializer.serialize(options.pageCursor, "string");
}
if (options.pageSize !== undefined) {
localVarQueryParameters['page[size]'] = ObjectSerializer.serialize(options.pageSize, "number");
}
if (options.sort !== undefined) {
localVarQueryParameters['sort'] = ObjectSerializer.serialize(options.sort, "'created' | '-created' | 'name' | '-name' | 'updated' | '-updated'");
}
queryParamPreProcessor(localVarQueryParameters)
let config: AxiosRequestConfig = {
method: 'GET',
url: localVarPath,
headers: localVarHeaderParams,
params: localVarQueryParameters,
}
await this.session.applyToRequest(config)
const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetWebFeedResponseCollection; }> => {
try {
const axiosResponse = await this.session.requestWithRetry(config)
let body;
body = ObjectSerializer.deserialize(axiosResponse.data, "GetWebFeedResponseCollection");
return ({response: axiosResponse, body: body});
} catch (error) {
if (await this.session.refreshAndRetry(error, retried)) {
await this.session.applyToRequest(config)
return request(config, true)
}
throw error
}
}
return request(config)
}
/**
* Update the web feed with the given ID.
*Rate limits*:
Burst: `1/s`
Steady: `15/m` **Scopes:** `web-feeds:write`
* @summary Update Web Feed
* @param id The ID of the web feed* @param webFeedPartialUpdateQuery Update a web feed by ID
*/
public async updateWebFeed (id: string, webFeedPartialUpdateQuery: WebFeedPartialUpdateQuery, ): Promise<{ response: AxiosResponse; body: PatchWebFeedResponse; }> {
const localVarPath = this.basePath + '/api/web-feeds/{id}'
.replace('{' + 'id' + '}', encodeURIComponent(String(id)));
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (Object).assign({}, this._defaultHeaders);
const produces = ['application/vnd.api+json'];
// give precedence to 'application/json'
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
} else {
localVarHeaderParams.Accept = produces.join(',');
}
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling updateWebFeed.');
}
// verify required parameter 'webFeedPartialUpdateQuery' is not null or undefined
if (webFeedPartialUpdateQuery === null || webFeedPartialUpdateQuery === undefined) {
throw new Error('Required parameter webFeedPartialUpdateQuery was null or undefined when calling updateWebFeed.');
}
queryParamPreProcessor(localVarQueryParameters)
let config: AxiosRequestConfig = {
method: 'PATCH',
url: localVarPath,
headers: localVarHeaderParams,
params: localVarQueryParameters,
data: ObjectSerializer.serialize(webFeedPartialUpdateQuery, "WebFeedPartialUpdateQuery")
}
await this.session.applyToRequest(config)
const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PatchWebFeedResponse; }> => {
try {
const axiosResponse = await this.session.requestWithRetry(config)
let body;
body = ObjectSerializer.deserialize(axiosResponse.data, "PatchWebFeedResponse");
return ({response: axiosResponse, body: body});
} catch (error) {
if (await this.session.refreshAndRetry(error, retried)) {
await this.session.applyToRequest(config)
return request(config, true)
}
throw error
}
}
return request(config)
}
}