/** * 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 { GetReviewResponseDTOCollectionCompoundDocument } from '../model/getReviewResponseDTOCollectionCompoundDocument'; import { GetReviewResponseDTOCompoundDocument } from '../model/getReviewResponseDTOCompoundDocument'; import { PatchReviewResponseDTO } from '../model/patchReviewResponseDTO'; import { ReviewPatchQuery } from '../model/reviewPatchQuery'; 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 ReviewsApi { 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; } /** * Get the review with the given ID.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `reviews:read` * @summary Get Review * @param id The ID of the review * @param fieldsEvent For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param fieldsReview For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param include For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#relationships */ public async getReview (id: string, options: { fieldsEvent?: Array<'datetime' | 'event_properties' | 'timestamp' | 'uuid'>, fieldsReview?: Array<'author' | 'content' | 'created' | 'email' | 'images' | 'product' | 'product.external_id' | 'product.image_url' | 'product.name' | 'product.url' | 'public_reply' | 'public_reply.author' | 'public_reply.content' | 'public_reply.updated' | 'rating' | 'review_type' | 'smart_quote' | 'status' | 'status.rejection_reason' | 'status.rejection_reason.reason' | 'status.rejection_reason.status_explanation' | 'status.value' | 'title' | 'updated' | 'verified'>, include?: Array<'events'>, } = {}): Promise<{ response: AxiosResponse; body: GetReviewResponseDTOCompoundDocument; }> { const localVarPath = this.basePath + '/api/reviews/{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 getReview.'); } if (options.fieldsEvent !== undefined) { localVarQueryParameters['fields[event]'] = ObjectSerializer.serialize(options.fieldsEvent, "Array<'datetime' | 'event_properties' | 'timestamp' | 'uuid'>"); } if (options.fieldsReview !== undefined) { localVarQueryParameters['fields[review]'] = ObjectSerializer.serialize(options.fieldsReview, "Array<'author' | 'content' | 'created' | 'email' | 'images' | 'product' | 'product.external_id' | 'product.image_url' | 'product.name' | 'product.url' | 'public_reply' | 'public_reply.author' | 'public_reply.content' | 'public_reply.updated' | 'rating' | 'review_type' | 'smart_quote' | 'status' | 'status.rejection_reason' | 'status.rejection_reason.reason' | 'status.rejection_reason.status_explanation' | 'status.value' | 'title' | 'updated' | 'verified'>"); } if (options.include !== undefined) { localVarQueryParameters['include'] = ObjectSerializer.serialize(options.include, "Array<'events'>"); } 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: GetReviewResponseDTOCompoundDocument; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetReviewResponseDTOCompoundDocument"); 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 reviews.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `reviews:read` * @summary Get Reviews * @param fieldsEvent For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sparse-fieldsets* @param fieldsReview 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>`created`: `greater-or-equal`, `less-or-equal`<br>`rating`: `any`, `equals`, `greater-or-equal`, `less-or-equal`<br>`id`: `any`, `equals`<br>`item.id`: `any`, `equals`<br>`content`: `contains`<br>`status`: `equals`<br>`review_type`: `equals`<br>`verified`: `equals`* @param include For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#relationships* @param pageCursor For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#pagination* @param pageSize Default: 20. Min: 1. Max: 100.* @param sort For more information please visit https://developers.klaviyo.com/en/v2026-04-15/reference/api-overview#sorting */ public async getReviews (options: { fieldsEvent?: Array<'datetime' | 'event_properties' | 'timestamp' | 'uuid'>, fieldsReview?: Array<'author' | 'content' | 'created' | 'email' | 'images' | 'product' | 'product.external_id' | 'product.image_url' | 'product.name' | 'product.url' | 'public_reply' | 'public_reply.author' | 'public_reply.content' | 'public_reply.updated' | 'rating' | 'review_type' | 'smart_quote' | 'status' | 'status.rejection_reason' | 'status.rejection_reason.reason' | 'status.rejection_reason.status_explanation' | 'status.value' | 'title' | 'updated' | 'verified'>, filter?: string, include?: Array<'events'>, pageCursor?: string, pageSize?: number, sort?: 'created' | '-created' | 'rating' | '-rating' | 'updated' | '-updated', } = {}): Promise<{ response: AxiosResponse; body: GetReviewResponseDTOCollectionCompoundDocument; }> { const localVarPath = this.basePath + '/api/reviews'; 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.fieldsEvent !== undefined) { localVarQueryParameters['fields[event]'] = ObjectSerializer.serialize(options.fieldsEvent, "Array<'datetime' | 'event_properties' | 'timestamp' | 'uuid'>"); } if (options.fieldsReview !== undefined) { localVarQueryParameters['fields[review]'] = ObjectSerializer.serialize(options.fieldsReview, "Array<'author' | 'content' | 'created' | 'email' | 'images' | 'product' | 'product.external_id' | 'product.image_url' | 'product.name' | 'product.url' | 'public_reply' | 'public_reply.author' | 'public_reply.content' | 'public_reply.updated' | 'rating' | 'review_type' | 'smart_quote' | 'status' | 'status.rejection_reason' | 'status.rejection_reason.reason' | 'status.rejection_reason.status_explanation' | 'status.value' | 'title' | 'updated' | 'verified'>"); } if (options.filter !== undefined) { localVarQueryParameters['filter'] = ObjectSerializer.serialize(options.filter, "string"); } if (options.include !== undefined) { localVarQueryParameters['include'] = ObjectSerializer.serialize(options.include, "Array<'events'>"); } 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' | 'rating' | '-rating' | '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: GetReviewResponseDTOCollectionCompoundDocument; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "GetReviewResponseDTOCollectionCompoundDocument"); 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 a review.

*Rate limits*:
Burst: `10/s`
Steady: `150/m` **Scopes:** `reviews:write` * @summary Update Review * @param id The id of the review (review ID).* @param reviewPatchQuery DTO for updating reviews */ public async updateReview (id: string, reviewPatchQuery: ReviewPatchQuery, ): Promise<{ response: AxiosResponse; body: PatchReviewResponseDTO; }> { const localVarPath = this.basePath + '/api/reviews/{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 updateReview.'); } // verify required parameter 'reviewPatchQuery' is not null or undefined if (reviewPatchQuery === null || reviewPatchQuery === undefined) { throw new Error('Required parameter reviewPatchQuery was null or undefined when calling updateReview.'); } queryParamPreProcessor(localVarQueryParameters) let config: AxiosRequestConfig = { method: 'PATCH', url: localVarPath, headers: localVarHeaderParams, params: localVarQueryParameters, data: ObjectSerializer.serialize(reviewPatchQuery, "ReviewPatchQuery") } await this.session.applyToRequest(config) const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: PatchReviewResponseDTO; }> => { try { const axiosResponse = await this.session.requestWithRetry(config) let body; body = ObjectSerializer.deserialize(axiosResponse.data, "PatchReviewResponseDTO"); 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) } }