@hubspot/api-client
Version:
NodeJS v3 [HubSpot API](https://developers.hubspot.com/docs/api/overview) SDK(Client) files
425 lines • 25.1 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ObjectSerializer = void 0;
__exportStar(require("../models/AppInfo"), exports);
__exportStar(require("../models/AttendanceCounters"), exports);
__exportStar(require("../models/BatchInputMarketingEventCreateRequestParams"), exports);
__exportStar(require("../models/BatchInputMarketingEventEmailSubscriber"), exports);
__exportStar(require("../models/BatchInputMarketingEventExternalUniqueIdentifier"), exports);
__exportStar(require("../models/BatchInputMarketingEventPublicObjectIdDeleteRequest"), exports);
__exportStar(require("../models/BatchInputMarketingEventPublicUpdateRequestFullV2"), exports);
__exportStar(require("../models/BatchInputMarketingEventSubscriber"), exports);
__exportStar(require("../models/BatchResponseMarketingEventPublicDefaultResponse"), exports);
__exportStar(require("../models/BatchResponseMarketingEventPublicDefaultResponseV2"), exports);
__exportStar(require("../models/BatchResponseMarketingEventPublicDefaultResponseV2WithErrors"), exports);
__exportStar(require("../models/BatchResponseSubscriberEmailResponse"), exports);
__exportStar(require("../models/BatchResponseSubscriberVidResponse"), exports);
__exportStar(require("../models/CollectionResponseMarketingEventPublicReadResponseV2ForwardPaging"), exports);
__exportStar(require("../models/CollectionResponseSearchPublicResponseWrapperNoPaging"), exports);
__exportStar(require("../models/CollectionResponseWithTotalMarketingEventIdentifiersResponseNoPaging"), exports);
__exportStar(require("../models/CollectionResponseWithTotalParticipationBreakdownForwardPaging"), exports);
__exportStar(require("../models/CollectionResponseWithTotalPublicListNoPaging"), exports);
__exportStar(require("../models/ContactAssociation"), exports);
__exportStar(require("../models/CrmPropertyWrapper"), exports);
__exportStar(require("../models/ErrorDetail"), exports);
__exportStar(require("../models/EventDetailSettings"), exports);
__exportStar(require("../models/EventDetailSettingsUrl"), exports);
__exportStar(require("../models/ForwardPaging"), exports);
__exportStar(require("../models/MarketingEventAssociation"), exports);
__exportStar(require("../models/MarketingEventCompleteRequestParams"), exports);
__exportStar(require("../models/MarketingEventCreateRequestParams"), exports);
__exportStar(require("../models/MarketingEventDefaultResponse"), exports);
__exportStar(require("../models/MarketingEventEmailSubscriber"), exports);
__exportStar(require("../models/MarketingEventExternalUniqueIdentifier"), exports);
__exportStar(require("../models/MarketingEventIdentifiersResponse"), exports);
__exportStar(require("../models/MarketingEventPublicDefaultResponse"), exports);
__exportStar(require("../models/MarketingEventPublicDefaultResponseV2"), exports);
__exportStar(require("../models/MarketingEventPublicObjectIdDeleteRequest"), exports);
__exportStar(require("../models/MarketingEventPublicReadResponse"), exports);
__exportStar(require("../models/MarketingEventPublicReadResponseV2"), exports);
__exportStar(require("../models/MarketingEventPublicUpdateRequestFullV2"), exports);
__exportStar(require("../models/MarketingEventPublicUpdateRequestV2"), exports);
__exportStar(require("../models/MarketingEventSubscriber"), exports);
__exportStar(require("../models/MarketingEventUpdateRequestParams"), exports);
__exportStar(require("../models/ModelError"), exports);
__exportStar(require("../models/NextPage"), exports);
__exportStar(require("../models/ParticipationAssociations"), exports);
__exportStar(require("../models/ParticipationBreakdown"), exports);
__exportStar(require("../models/ParticipationProperties"), exports);
__exportStar(require("../models/PropertyValue"), exports);
__exportStar(require("../models/PublicList"), exports);
__exportStar(require("../models/SearchPublicResponseWrapper"), exports);
__exportStar(require("../models/StandardError"), exports);
__exportStar(require("../models/SubscriberEmailResponse"), exports);
__exportStar(require("../models/SubscriberVidResponse"), exports);
const AppInfo_1 = require("../models/AppInfo");
const AttendanceCounters_1 = require("../models/AttendanceCounters");
const BatchInputMarketingEventCreateRequestParams_1 = require("../models/BatchInputMarketingEventCreateRequestParams");
const BatchInputMarketingEventEmailSubscriber_1 = require("../models/BatchInputMarketingEventEmailSubscriber");
const BatchInputMarketingEventExternalUniqueIdentifier_1 = require("../models/BatchInputMarketingEventExternalUniqueIdentifier");
const BatchInputMarketingEventPublicObjectIdDeleteRequest_1 = require("../models/BatchInputMarketingEventPublicObjectIdDeleteRequest");
const BatchInputMarketingEventPublicUpdateRequestFullV2_1 = require("../models/BatchInputMarketingEventPublicUpdateRequestFullV2");
const BatchInputMarketingEventSubscriber_1 = require("../models/BatchInputMarketingEventSubscriber");
const BatchResponseMarketingEventPublicDefaultResponse_1 = require("../models/BatchResponseMarketingEventPublicDefaultResponse");
const BatchResponseMarketingEventPublicDefaultResponseV2_1 = require("../models/BatchResponseMarketingEventPublicDefaultResponseV2");
const BatchResponseMarketingEventPublicDefaultResponseV2WithErrors_1 = require("../models/BatchResponseMarketingEventPublicDefaultResponseV2WithErrors");
const BatchResponseSubscriberEmailResponse_1 = require("../models/BatchResponseSubscriberEmailResponse");
const BatchResponseSubscriberVidResponse_1 = require("../models/BatchResponseSubscriberVidResponse");
const CollectionResponseMarketingEventPublicReadResponseV2ForwardPaging_1 = require("../models/CollectionResponseMarketingEventPublicReadResponseV2ForwardPaging");
const CollectionResponseSearchPublicResponseWrapperNoPaging_1 = require("../models/CollectionResponseSearchPublicResponseWrapperNoPaging");
const CollectionResponseWithTotalMarketingEventIdentifiersResponseNoPaging_1 = require("../models/CollectionResponseWithTotalMarketingEventIdentifiersResponseNoPaging");
const CollectionResponseWithTotalParticipationBreakdownForwardPaging_1 = require("../models/CollectionResponseWithTotalParticipationBreakdownForwardPaging");
const CollectionResponseWithTotalPublicListNoPaging_1 = require("../models/CollectionResponseWithTotalPublicListNoPaging");
const ContactAssociation_1 = require("../models/ContactAssociation");
const CrmPropertyWrapper_1 = require("../models/CrmPropertyWrapper");
const ErrorDetail_1 = require("../models/ErrorDetail");
const EventDetailSettings_1 = require("../models/EventDetailSettings");
const EventDetailSettingsUrl_1 = require("../models/EventDetailSettingsUrl");
const ForwardPaging_1 = require("../models/ForwardPaging");
const MarketingEventAssociation_1 = require("../models/MarketingEventAssociation");
const MarketingEventCompleteRequestParams_1 = require("../models/MarketingEventCompleteRequestParams");
const MarketingEventCreateRequestParams_1 = require("../models/MarketingEventCreateRequestParams");
const MarketingEventDefaultResponse_1 = require("../models/MarketingEventDefaultResponse");
const MarketingEventEmailSubscriber_1 = require("../models/MarketingEventEmailSubscriber");
const MarketingEventExternalUniqueIdentifier_1 = require("../models/MarketingEventExternalUniqueIdentifier");
const MarketingEventIdentifiersResponse_1 = require("../models/MarketingEventIdentifiersResponse");
const MarketingEventPublicDefaultResponse_1 = require("../models/MarketingEventPublicDefaultResponse");
const MarketingEventPublicDefaultResponseV2_1 = require("../models/MarketingEventPublicDefaultResponseV2");
const MarketingEventPublicObjectIdDeleteRequest_1 = require("../models/MarketingEventPublicObjectIdDeleteRequest");
const MarketingEventPublicReadResponse_1 = require("../models/MarketingEventPublicReadResponse");
const MarketingEventPublicReadResponseV2_1 = require("../models/MarketingEventPublicReadResponseV2");
const MarketingEventPublicUpdateRequestFullV2_1 = require("../models/MarketingEventPublicUpdateRequestFullV2");
const MarketingEventPublicUpdateRequestV2_1 = require("../models/MarketingEventPublicUpdateRequestV2");
const MarketingEventSubscriber_1 = require("../models/MarketingEventSubscriber");
const MarketingEventUpdateRequestParams_1 = require("../models/MarketingEventUpdateRequestParams");
const ModelError_1 = require("../models/ModelError");
const NextPage_1 = require("../models/NextPage");
const ParticipationAssociations_1 = require("../models/ParticipationAssociations");
const ParticipationBreakdown_1 = require("../models/ParticipationBreakdown");
const ParticipationProperties_1 = require("../models/ParticipationProperties");
const PropertyValue_1 = require("../models/PropertyValue");
const PublicList_1 = require("../models/PublicList");
const SearchPublicResponseWrapper_1 = require("../models/SearchPublicResponseWrapper");
const StandardError_1 = require("../models/StandardError");
const SubscriberEmailResponse_1 = require("../models/SubscriberEmailResponse");
const SubscriberVidResponse_1 = require("../models/SubscriberVidResponse");
let primitives = [
"string",
"boolean",
"double",
"integer",
"long",
"float",
"number",
"any"
];
let enumsMap = new Set([
"BatchResponseMarketingEventPublicDefaultResponseStatusEnum",
"BatchResponseMarketingEventPublicDefaultResponseV2StatusEnum",
"BatchResponseMarketingEventPublicDefaultResponseV2WithErrorsStatusEnum",
"BatchResponseSubscriberEmailResponseStatusEnum",
"BatchResponseSubscriberVidResponseStatusEnum",
"ParticipationPropertiesAttendanceStateEnum",
"PropertyValueSourceEnum",
"PropertyValueDataSensitivityEnum",
]);
let typeMap = {
"AppInfo": AppInfo_1.AppInfo,
"AttendanceCounters": AttendanceCounters_1.AttendanceCounters,
"BatchInputMarketingEventCreateRequestParams": BatchInputMarketingEventCreateRequestParams_1.BatchInputMarketingEventCreateRequestParams,
"BatchInputMarketingEventEmailSubscriber": BatchInputMarketingEventEmailSubscriber_1.BatchInputMarketingEventEmailSubscriber,
"BatchInputMarketingEventExternalUniqueIdentifier": BatchInputMarketingEventExternalUniqueIdentifier_1.BatchInputMarketingEventExternalUniqueIdentifier,
"BatchInputMarketingEventPublicObjectIdDeleteRequest": BatchInputMarketingEventPublicObjectIdDeleteRequest_1.BatchInputMarketingEventPublicObjectIdDeleteRequest,
"BatchInputMarketingEventPublicUpdateRequestFullV2": BatchInputMarketingEventPublicUpdateRequestFullV2_1.BatchInputMarketingEventPublicUpdateRequestFullV2,
"BatchInputMarketingEventSubscriber": BatchInputMarketingEventSubscriber_1.BatchInputMarketingEventSubscriber,
"BatchResponseMarketingEventPublicDefaultResponse": BatchResponseMarketingEventPublicDefaultResponse_1.BatchResponseMarketingEventPublicDefaultResponse,
"BatchResponseMarketingEventPublicDefaultResponseV2": BatchResponseMarketingEventPublicDefaultResponseV2_1.BatchResponseMarketingEventPublicDefaultResponseV2,
"BatchResponseMarketingEventPublicDefaultResponseV2WithErrors": BatchResponseMarketingEventPublicDefaultResponseV2WithErrors_1.BatchResponseMarketingEventPublicDefaultResponseV2WithErrors,
"BatchResponseSubscriberEmailResponse": BatchResponseSubscriberEmailResponse_1.BatchResponseSubscriberEmailResponse,
"BatchResponseSubscriberVidResponse": BatchResponseSubscriberVidResponse_1.BatchResponseSubscriberVidResponse,
"CollectionResponseMarketingEventPublicReadResponseV2ForwardPaging": CollectionResponseMarketingEventPublicReadResponseV2ForwardPaging_1.CollectionResponseMarketingEventPublicReadResponseV2ForwardPaging,
"CollectionResponseSearchPublicResponseWrapperNoPaging": CollectionResponseSearchPublicResponseWrapperNoPaging_1.CollectionResponseSearchPublicResponseWrapperNoPaging,
"CollectionResponseWithTotalMarketingEventIdentifiersResponseNoPaging": CollectionResponseWithTotalMarketingEventIdentifiersResponseNoPaging_1.CollectionResponseWithTotalMarketingEventIdentifiersResponseNoPaging,
"CollectionResponseWithTotalParticipationBreakdownForwardPaging": CollectionResponseWithTotalParticipationBreakdownForwardPaging_1.CollectionResponseWithTotalParticipationBreakdownForwardPaging,
"CollectionResponseWithTotalPublicListNoPaging": CollectionResponseWithTotalPublicListNoPaging_1.CollectionResponseWithTotalPublicListNoPaging,
"ContactAssociation": ContactAssociation_1.ContactAssociation,
"CrmPropertyWrapper": CrmPropertyWrapper_1.CrmPropertyWrapper,
"ErrorDetail": ErrorDetail_1.ErrorDetail,
"EventDetailSettings": EventDetailSettings_1.EventDetailSettings,
"EventDetailSettingsUrl": EventDetailSettingsUrl_1.EventDetailSettingsUrl,
"ForwardPaging": ForwardPaging_1.ForwardPaging,
"MarketingEventAssociation": MarketingEventAssociation_1.MarketingEventAssociation,
"MarketingEventCompleteRequestParams": MarketingEventCompleteRequestParams_1.MarketingEventCompleteRequestParams,
"MarketingEventCreateRequestParams": MarketingEventCreateRequestParams_1.MarketingEventCreateRequestParams,
"MarketingEventDefaultResponse": MarketingEventDefaultResponse_1.MarketingEventDefaultResponse,
"MarketingEventEmailSubscriber": MarketingEventEmailSubscriber_1.MarketingEventEmailSubscriber,
"MarketingEventExternalUniqueIdentifier": MarketingEventExternalUniqueIdentifier_1.MarketingEventExternalUniqueIdentifier,
"MarketingEventIdentifiersResponse": MarketingEventIdentifiersResponse_1.MarketingEventIdentifiersResponse,
"MarketingEventPublicDefaultResponse": MarketingEventPublicDefaultResponse_1.MarketingEventPublicDefaultResponse,
"MarketingEventPublicDefaultResponseV2": MarketingEventPublicDefaultResponseV2_1.MarketingEventPublicDefaultResponseV2,
"MarketingEventPublicObjectIdDeleteRequest": MarketingEventPublicObjectIdDeleteRequest_1.MarketingEventPublicObjectIdDeleteRequest,
"MarketingEventPublicReadResponse": MarketingEventPublicReadResponse_1.MarketingEventPublicReadResponse,
"MarketingEventPublicReadResponseV2": MarketingEventPublicReadResponseV2_1.MarketingEventPublicReadResponseV2,
"MarketingEventPublicUpdateRequestFullV2": MarketingEventPublicUpdateRequestFullV2_1.MarketingEventPublicUpdateRequestFullV2,
"MarketingEventPublicUpdateRequestV2": MarketingEventPublicUpdateRequestV2_1.MarketingEventPublicUpdateRequestV2,
"MarketingEventSubscriber": MarketingEventSubscriber_1.MarketingEventSubscriber,
"MarketingEventUpdateRequestParams": MarketingEventUpdateRequestParams_1.MarketingEventUpdateRequestParams,
"ModelError": ModelError_1.ModelError,
"NextPage": NextPage_1.NextPage,
"ParticipationAssociations": ParticipationAssociations_1.ParticipationAssociations,
"ParticipationBreakdown": ParticipationBreakdown_1.ParticipationBreakdown,
"ParticipationProperties": ParticipationProperties_1.ParticipationProperties,
"PropertyValue": PropertyValue_1.PropertyValue,
"PublicList": PublicList_1.PublicList,
"SearchPublicResponseWrapper": SearchPublicResponseWrapper_1.SearchPublicResponseWrapper,
"StandardError": StandardError_1.StandardError,
"SubscriberEmailResponse": SubscriberEmailResponse_1.SubscriberEmailResponse,
"SubscriberVidResponse": SubscriberVidResponse_1.SubscriberVidResponse,
};
const parseMimeType = (mimeType) => {
const [type = '', subtype = ''] = mimeType.split('/');
return {
type,
subtype,
subtypeTokens: subtype.split('+'),
};
};
const mimeTypePredicateFactory = (predicate) => (mimeType) => predicate(parseMimeType(mimeType));
const mimeTypeSimplePredicateFactory = (type, subtype) => mimeTypePredicateFactory((descriptor) => {
if (descriptor.type !== type)
return false;
if (subtype != null && descriptor.subtype !== subtype)
return false;
return true;
});
const isTextLikeMimeType = mimeTypeSimplePredicateFactory('text');
const isJsonMimeType = mimeTypeSimplePredicateFactory('application', 'json');
const isJsonLikeMimeType = mimeTypePredicateFactory((descriptor) => descriptor.type === 'application' && descriptor.subtypeTokens.some((item) => item === 'json'));
const isOctetStreamMimeType = mimeTypeSimplePredicateFactory('application', 'octet-stream');
const isFormUrlencodedMimeType = mimeTypeSimplePredicateFactory('application', 'x-www-form-urlencoded');
const supportedMimeTypePredicatesWithPriority = [
isJsonMimeType,
isJsonLikeMimeType,
isTextLikeMimeType,
isOctetStreamMimeType,
isFormUrlencodedMimeType,
];
const nullableSuffix = " | null";
const optionalSuffix = " | undefined";
const arrayPrefix = "Array<";
const arraySuffix = ">";
const mapPrefix = "{ [key: string]: ";
const mapSuffix = "; }";
class ObjectSerializer {
static findCorrectType(data, expectedType) {
if (data == undefined) {
return expectedType;
}
else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) {
return expectedType;
}
else if (expectedType === "Date") {
return expectedType;
}
else {
if (enumsMap.has(expectedType)) {
return expectedType;
}
if (!typeMap[expectedType]) {
return expectedType;
}
let discriminatorProperty = typeMap[expectedType].discriminator;
if (discriminatorProperty == null) {
return expectedType;
}
else {
if (data[discriminatorProperty]) {
var discriminatorType = data[discriminatorProperty];
let mapping = typeMap[expectedType].mapping;
if (mapping != undefined && mapping[discriminatorType]) {
return mapping[discriminatorType];
}
else if (typeMap[discriminatorType]) {
return discriminatorType;
}
else {
return expectedType;
}
}
else {
return expectedType;
}
}
}
}
static serialize(data, type, format) {
if (data == undefined) {
return data;
}
else if (primitives.indexOf(type.toLowerCase()) !== -1) {
return data;
}
else if (type.endsWith(nullableSuffix)) {
let subType = type.slice(0, -nullableSuffix.length);
return ObjectSerializer.serialize(data, subType, format);
}
else if (type.endsWith(optionalSuffix)) {
let subType = type.slice(0, -optionalSuffix.length);
return ObjectSerializer.serialize(data, subType, format);
}
else if (type.startsWith(arrayPrefix)) {
let subType = type.slice(arrayPrefix.length, -arraySuffix.length);
let transformedData = [];
for (let date of data) {
transformedData.push(ObjectSerializer.serialize(date, subType, format));
}
return transformedData;
}
else if (type.startsWith(mapPrefix)) {
let subType = type.slice(mapPrefix.length, -mapSuffix.length);
let transformedData = {};
for (let key in data) {
transformedData[key] = ObjectSerializer.serialize(data[key], subType, format);
}
return transformedData;
}
else if (type === "Date") {
if (format == "date") {
let month = data.getMonth() + 1;
month = month < 10 ? "0" + month.toString() : month.toString();
let day = data.getDate();
day = day < 10 ? "0" + day.toString() : day.toString();
return data.getFullYear() + "-" + month + "-" + day;
}
else {
return data.toISOString();
}
}
else {
if (enumsMap.has(type)) {
return data;
}
if (!typeMap[type]) {
return data;
}
type = this.findCorrectType(data, type);
let attributeTypes = typeMap[type].getAttributeTypeMap();
let instance = {};
for (let attributeType of attributeTypes) {
instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format);
}
return instance;
}
}
static deserialize(data, type, format) {
type = ObjectSerializer.findCorrectType(data, type);
if (data == undefined) {
return data;
}
else if (primitives.indexOf(type.toLowerCase()) !== -1) {
return data;
}
else if (type.endsWith(nullableSuffix)) {
let subType = type.slice(0, -nullableSuffix.length);
return ObjectSerializer.deserialize(data, subType, format);
}
else if (type.endsWith(optionalSuffix)) {
let subType = type.slice(0, -optionalSuffix.length);
return ObjectSerializer.deserialize(data, subType, format);
}
else if (type.startsWith(arrayPrefix)) {
let subType = type.slice(arrayPrefix.length, -arraySuffix.length);
let transformedData = [];
for (let date of data) {
transformedData.push(ObjectSerializer.deserialize(date, subType, format));
}
return transformedData;
}
else if (type.startsWith(mapPrefix)) {
let subType = type.slice(mapPrefix.length, -mapSuffix.length);
let transformedData = {};
for (let key in data) {
transformedData[key] = ObjectSerializer.deserialize(data[key], subType, format);
}
return transformedData;
}
else if (type === "Date") {
return new Date(data);
}
else {
if (enumsMap.has(type)) {
return data;
}
if (!typeMap[type]) {
return data;
}
let instance = new typeMap[type]();
let attributeTypes = typeMap[type].getAttributeTypeMap();
for (let attributeType of attributeTypes) {
let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format);
if (value !== undefined) {
instance[attributeType.name] = value;
}
}
return instance;
}
}
static normalizeMediaType(mediaType) {
var _a;
if (mediaType === undefined) {
return undefined;
}
return ((_a = mediaType.split(";")[0]) !== null && _a !== void 0 ? _a : '').trim().toLowerCase();
}
static getPreferredMediaType(mediaTypes) {
if (mediaTypes.length === 0) {
return "application/json";
}
const normalMediaTypes = mediaTypes.map(ObjectSerializer.normalizeMediaType);
for (const predicate of supportedMimeTypePredicatesWithPriority) {
for (const mediaType of normalMediaTypes) {
if (mediaType != null && predicate(mediaType)) {
return mediaType;
}
}
}
throw new Error("None of the given media types are supported: " + mediaTypes.join(", "));
}
static stringify(data, mediaType) {
if (isTextLikeMimeType(mediaType)) {
return String(data);
}
if (isJsonLikeMimeType(mediaType)) {
return JSON.stringify(data);
}
throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify.");
}
static parse(rawData, mediaType) {
if (mediaType === undefined) {
throw new Error("Cannot parse content. No Content-Type defined.");
}
if (isTextLikeMimeType(mediaType)) {
return rawData;
}
if (isJsonLikeMimeType(mediaType)) {
return JSON.parse(rawData);
}
throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse.");
}
}
exports.ObjectSerializer = ObjectSerializer;
//# sourceMappingURL=ObjectSerializer.js.map