UNPKG

@hubspot/api-client

Version:

NodeJS v3 [HubSpot API](https://developers.hubspot.com/docs/api/overview) SDK(Client) files

690 lines 63.2 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.MarketingEmailsApiResponseProcessor = exports.MarketingEmailsApiRequestFactory = void 0; const baseapi_1 = require("./baseapi"); const http_1 = require("../http/http"); const ObjectSerializer_1 = require("../models/ObjectSerializer"); const exception_1 = require("./exception"); const util_1 = require("../util"); class MarketingEmailsApiRequestFactory extends baseapi_1.BaseAPIRequestFactory { archive(emailId, archived, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "archive", "emailId"); } const localVarPath = '/marketing/v3/emails/{emailId}' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.DELETE); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); if (archived !== undefined) { requestContext.setQueryParam("archived", ObjectSerializer_1.ObjectSerializer.serialize(archived, "boolean", "")); } let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } clone(contentCloneRequestVNext, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (contentCloneRequestVNext === null || contentCloneRequestVNext === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "clone", "contentCloneRequestVNext"); } const localVarPath = '/marketing/v3/emails/clone'; const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); const contentType = ObjectSerializer_1.ObjectSerializer.getPreferredMediaType([ "application/json" ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer_1.ObjectSerializer.stringify(ObjectSerializer_1.ObjectSerializer.serialize(contentCloneRequestVNext, "ContentCloneRequestVNext", ""), contentType); requestContext.setBody(serializedBody); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } create(emailCreateRequest, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailCreateRequest === null || emailCreateRequest === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "create", "emailCreateRequest"); } const localVarPath = '/marketing/v3/emails/'; const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); const contentType = ObjectSerializer_1.ObjectSerializer.getPreferredMediaType([ "application/json" ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer_1.ObjectSerializer.stringify(ObjectSerializer_1.ObjectSerializer.serialize(emailCreateRequest, "EmailCreateRequest", ""), contentType); requestContext.setBody(serializedBody); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } createAbTestVariation(abTestCreateRequestVNext, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (abTestCreateRequestVNext === null || abTestCreateRequestVNext === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "createAbTestVariation", "abTestCreateRequestVNext"); } const localVarPath = '/marketing/v3/emails/ab-test/create-variation'; const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); const contentType = ObjectSerializer_1.ObjectSerializer.getPreferredMediaType([ "application/json" ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer_1.ObjectSerializer.stringify(ObjectSerializer_1.ObjectSerializer.serialize(abTestCreateRequestVNext, "AbTestCreateRequestVNext", ""), contentType); requestContext.setBody(serializedBody); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } getAbTestVariation(emailId, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "getAbTestVariation", "emailId"); } const localVarPath = '/marketing/v3/emails/{emailId}/ab-test/get-variation' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } getById(emailId, includeStats, marketingCampaignNames, workflowNames, includedProperties, archived, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "getById", "emailId"); } const localVarPath = '/marketing/v3/emails/{emailId}' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); if (includeStats !== undefined) { requestContext.setQueryParam("includeStats", ObjectSerializer_1.ObjectSerializer.serialize(includeStats, "boolean", "")); } if (marketingCampaignNames !== undefined) { requestContext.setQueryParam("marketingCampaignNames", ObjectSerializer_1.ObjectSerializer.serialize(marketingCampaignNames, "boolean", "")); } if (workflowNames !== undefined) { requestContext.setQueryParam("workflowNames", ObjectSerializer_1.ObjectSerializer.serialize(workflowNames, "boolean", "")); } if (includedProperties !== undefined) { const serializedParams = ObjectSerializer_1.ObjectSerializer.serialize(includedProperties, "Array<string>", ""); for (const serializedParam of serializedParams) { requestContext.appendQueryParam("includedProperties", serializedParam); } } if (archived !== undefined) { requestContext.setQueryParam("archived", ObjectSerializer_1.ObjectSerializer.serialize(archived, "boolean", "")); } let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } getDraft(emailId, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "getDraft", "emailId"); } const localVarPath = '/marketing/v3/emails/{emailId}/draft' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } getPage(createdAt, createdAfter, createdBefore, updatedAt, updatedAfter, updatedBefore, sort, after, limit, includeStats, marketingCampaignNames, workflowNames, type, isPublished, includedProperties, campaign, archived, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; const localVarPath = '/marketing/v3/emails/'; const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); if (createdAt !== undefined) { requestContext.setQueryParam("createdAt", ObjectSerializer_1.ObjectSerializer.serialize(createdAt, "Date", "date-time")); } if (createdAfter !== undefined) { requestContext.setQueryParam("createdAfter", ObjectSerializer_1.ObjectSerializer.serialize(createdAfter, "Date", "date-time")); } if (createdBefore !== undefined) { requestContext.setQueryParam("createdBefore", ObjectSerializer_1.ObjectSerializer.serialize(createdBefore, "Date", "date-time")); } if (updatedAt !== undefined) { requestContext.setQueryParam("updatedAt", ObjectSerializer_1.ObjectSerializer.serialize(updatedAt, "Date", "date-time")); } if (updatedAfter !== undefined) { requestContext.setQueryParam("updatedAfter", ObjectSerializer_1.ObjectSerializer.serialize(updatedAfter, "Date", "date-time")); } if (updatedBefore !== undefined) { requestContext.setQueryParam("updatedBefore", ObjectSerializer_1.ObjectSerializer.serialize(updatedBefore, "Date", "date-time")); } if (sort !== undefined) { const serializedParams = ObjectSerializer_1.ObjectSerializer.serialize(sort, "Array<string>", ""); for (const serializedParam of serializedParams) { requestContext.appendQueryParam("sort", serializedParam); } } if (after !== undefined) { requestContext.setQueryParam("after", ObjectSerializer_1.ObjectSerializer.serialize(after, "string", "")); } if (limit !== undefined) { requestContext.setQueryParam("limit", ObjectSerializer_1.ObjectSerializer.serialize(limit, "number", "int32")); } if (includeStats !== undefined) { requestContext.setQueryParam("includeStats", ObjectSerializer_1.ObjectSerializer.serialize(includeStats, "boolean", "")); } if (marketingCampaignNames !== undefined) { requestContext.setQueryParam("marketingCampaignNames", ObjectSerializer_1.ObjectSerializer.serialize(marketingCampaignNames, "boolean", "")); } if (workflowNames !== undefined) { requestContext.setQueryParam("workflowNames", ObjectSerializer_1.ObjectSerializer.serialize(workflowNames, "boolean", "")); } if (type !== undefined) { requestContext.setQueryParam("type", ObjectSerializer_1.ObjectSerializer.serialize(type, "'AB_EMAIL' | 'BATCH_EMAIL' | 'LOCALTIME_EMAIL' | 'AUTOMATED_AB_EMAIL' | 'BLOG_EMAIL' | 'BLOG_EMAIL_CHILD' | 'RSS_EMAIL' | 'RSS_EMAIL_CHILD' | 'RESUBSCRIBE_EMAIL' | 'OPTIN_EMAIL' | 'OPTIN_FOLLOWUP_EMAIL' | 'AUTOMATED_EMAIL' | 'FEEDBACK_CES_EMAIL' | 'FEEDBACK_CUSTOM_EMAIL' | 'FEEDBACK_CUSTOM_SURVEY_EMAIL' | 'FEEDBACK_NPS_EMAIL' | 'FOLLOWUP_EMAIL' | 'LEADFLOW_EMAIL' | 'SINGLE_SEND_API' | 'MARKETING_SINGLE_SEND_API' | 'SMTP_TOKEN' | 'TICKET_EMAIL' | 'MEMBERSHIP_REGISTRATION_EMAIL' | 'MEMBERSHIP_PASSWORD_SAVED_EMAIL' | 'MEMBERSHIP_PASSWORD_RESET_EMAIL' | 'MEMBERSHIP_EMAIL_VERIFICATION_EMAIL' | 'MEMBERSHIP_PASSWORDLESS_AUTH_EMAIL' | 'MEMBERSHIP_REGISTRATION_FOLLOW_UP_EMAIL' | 'MEMBERSHIP_OTP_LOGIN_EMAIL' | 'MEMBERSHIP_FOLLOW_UP_EMAIL' | 'MEMBERSHIP_VERIFICATION_EMAIL'", "")); } if (isPublished !== undefined) { requestContext.setQueryParam("isPublished", ObjectSerializer_1.ObjectSerializer.serialize(isPublished, "boolean", "")); } if (includedProperties !== undefined) { const serializedParams = ObjectSerializer_1.ObjectSerializer.serialize(includedProperties, "Array<string>", ""); for (const serializedParam of serializedParams) { requestContext.appendQueryParam("includedProperties", serializedParam); } } if (campaign !== undefined) { requestContext.setQueryParam("campaign", ObjectSerializer_1.ObjectSerializer.serialize(campaign, "string", "")); } if (archived !== undefined) { requestContext.setQueryParam("archived", ObjectSerializer_1.ObjectSerializer.serialize(archived, "boolean", "")); } let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } getRevisionById(emailId, revisionId, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "getRevisionById", "emailId"); } if (revisionId === null || revisionId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "getRevisionById", "revisionId"); } const localVarPath = '/marketing/v3/emails/{emailId}/revisions/{revisionId}' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))) .replace('{' + 'revisionId' + '}', encodeURIComponent(String(revisionId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } getRevisions(emailId, after, before, limit, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "getRevisions", "emailId"); } const localVarPath = '/marketing/v3/emails/{emailId}/revisions' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); if (after !== undefined) { requestContext.setQueryParam("after", ObjectSerializer_1.ObjectSerializer.serialize(after, "string", "")); } if (before !== undefined) { requestContext.setQueryParam("before", ObjectSerializer_1.ObjectSerializer.serialize(before, "string", "")); } if (limit !== undefined) { requestContext.setQueryParam("limit", ObjectSerializer_1.ObjectSerializer.serialize(limit, "number", "int32")); } let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } publishOrSend(emailId, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "publishOrSend", "emailId"); } const localVarPath = '/marketing/v3/emails/{emailId}/publish' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } resetDraft(emailId, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "resetDraft", "emailId"); } const localVarPath = '/marketing/v3/emails/{emailId}/draft/reset' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } restoreDraftRevision(emailId, revisionId, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "restoreDraftRevision", "emailId"); } if (revisionId === null || revisionId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "restoreDraftRevision", "revisionId"); } const localVarPath = '/marketing/v3/emails/{emailId}/revisions/{revisionId}/restore-to-draft' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))) .replace('{' + 'revisionId' + '}', encodeURIComponent(String(revisionId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } restoreRevision(emailId, revisionId, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "restoreRevision", "emailId"); } if (revisionId === null || revisionId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "restoreRevision", "revisionId"); } const localVarPath = '/marketing/v3/emails/{emailId}/revisions/{revisionId}/restore' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))) .replace('{' + 'revisionId' + '}', encodeURIComponent(String(revisionId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } unpublishOrCancel(emailId, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "unpublishOrCancel", "emailId"); } const localVarPath = '/marketing/v3/emails/{emailId}/unpublish' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.POST); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } update(emailId, emailUpdateRequest, archived, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "update", "emailId"); } if (emailUpdateRequest === null || emailUpdateRequest === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "update", "emailUpdateRequest"); } const localVarPath = '/marketing/v3/emails/{emailId}' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.PATCH); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); if (archived !== undefined) { requestContext.setQueryParam("archived", ObjectSerializer_1.ObjectSerializer.serialize(archived, "boolean", "")); } const contentType = ObjectSerializer_1.ObjectSerializer.getPreferredMediaType([ "application/json" ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer_1.ObjectSerializer.stringify(ObjectSerializer_1.ObjectSerializer.serialize(emailUpdateRequest, "EmailUpdateRequest", ""), contentType); requestContext.setBody(serializedBody); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } upsertDraft(emailId, emailUpdateRequest, _options) { var _a; return __awaiter(this, void 0, void 0, function* () { let _config = _options || this.configuration; if (emailId === null || emailId === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "upsertDraft", "emailId"); } if (emailUpdateRequest === null || emailUpdateRequest === undefined) { throw new baseapi_1.RequiredError("MarketingEmailsApi", "upsertDraft", "emailUpdateRequest"); } const localVarPath = '/marketing/v3/emails/{emailId}/draft' .replace('{' + 'emailId' + '}', encodeURIComponent(String(emailId))); const requestContext = _config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.PATCH); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); const contentType = ObjectSerializer_1.ObjectSerializer.getPreferredMediaType([ "application/json" ]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = ObjectSerializer_1.ObjectSerializer.stringify(ObjectSerializer_1.ObjectSerializer.serialize(emailUpdateRequest, "EmailUpdateRequest", ""), contentType); requestContext.setBody(serializedBody); let authMethod; authMethod = _config.authMethods["oauth2"]; if (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication) { yield (authMethod === null || authMethod === void 0 ? void 0 : authMethod.applySecurityAuthentication(requestContext)); } const defaultAuth = (_a = _config === null || _config === void 0 ? void 0 : _config.authMethods) === null || _a === void 0 ? void 0 : _a.default; if (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication) { yield (defaultAuth === null || defaultAuth === void 0 ? void 0 : defaultAuth.applySecurityAuthentication(requestContext)); } return requestContext; }); } } exports.MarketingEmailsApiRequestFactory = MarketingEmailsApiRequestFactory; class MarketingEmailsApiResponseProcessor { archiveWithHttpInfo(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if ((0, util_1.isCodeInRange)("204", response.httpStatusCode)) { return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, undefined); } if ((0, util_1.isCodeInRange)("0", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "Error", ""); throw new exception_1.ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); } if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "void", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!", yield response.getBodyAsAny(), response.headers); }); } cloneWithHttpInfo(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if ((0, util_1.isCodeInRange)("200", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "PublicEmail", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } if ((0, util_1.isCodeInRange)("0", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "Error", ""); throw new exception_1.ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); } if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "PublicEmail", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!", yield response.getBodyAsAny(), response.headers); }); } createWithHttpInfo(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if ((0, util_1.isCodeInRange)("201", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "PublicEmail", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } if ((0, util_1.isCodeInRange)("0", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "Error", ""); throw new exception_1.ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); } if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "PublicEmail", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!", yield response.getBodyAsAny(), response.headers); }); } createAbTestVariationWithHttpInfo(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if ((0, util_1.isCodeInRange)("201", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "PublicEmail", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } if ((0, util_1.isCodeInRange)("0", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "Error", ""); throw new exception_1.ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); } if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "PublicEmail", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!", yield response.getBodyAsAny(), response.headers); }); } getAbTestVariationWithHttpInfo(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if ((0, util_1.isCodeInRange)("200", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "PublicEmail", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } if ((0, util_1.isCodeInRange)("0", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "Error", ""); throw new exception_1.ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); } if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "PublicEmail", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!", yield response.getBodyAsAny(), response.headers); }); } getByIdWithHttpInfo(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if ((0, util_1.isCodeInRange)("200", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "PublicEmail", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } if ((0, util_1.isCodeInRange)("0", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "Error", ""); throw new exception_1.ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); } if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "PublicEmail", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!", yield response.getBodyAsAny(), response.headers); }); } getDraftWithHttpInfo(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if ((0, util_1.isCodeInRange)("200", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "PublicEmail", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } if ((0, util_1.isCodeInRange)("0", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "Error", ""); throw new exception_1.ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); } if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "PublicEmail", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!", yield response.getBodyAsAny(), response.headers); }); } getPageWithHttpInfo(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if ((0, util_1.isCodeInRange)("200", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "CollectionResponseWithTotalPublicEmailForwardPaging", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } if ((0, util_1.isCodeInRange)("0", response.httpStatusCode)) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "Error", ""); throw new exception_1.ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); } if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "CollectionResponseWithTotalPublicEmailForwardPaging", ""); return new http_1.HttpInfo(response.httpStatusCode, response.headers, response.body, body); } throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!", yield response.getBodyAsAny(), response.headers); }); } getRevisionByIdWithHttpInfo(response) { return __awaiter(this, void 0, void 0, function* () { const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if ((0, util_1.is