diff --git a/codegen/marketing/forms/apis/FormsApi.ts b/codegen/marketing/forms/apis/FormsApi.ts new file mode 100644 index 000000000..51960a6aa --- /dev/null +++ b/codegen/marketing/forms/apis/FormsApi.ts @@ -0,0 +1,541 @@ +// TODO: better import syntax? +import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi'; +import {Configuration} from '../configuration'; +import {RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; +import FormData from "form-data"; +import { URLSearchParams } from 'url'; +import {ObjectSerializer} from '../models/ObjectSerializer'; +import {ApiException} from './exception'; +import {canConsumeForm, isCodeInRange} from '../util'; +import {SecurityAuthentication} from '../auth/auth'; + + +import { CollectionResponseFormDefinitionBaseForwardPaging } from '../models/CollectionResponseFormDefinitionBaseForwardPaging'; +import { FormDefinitionBase } from '../models/FormDefinitionBase'; +import { FormDefinitionCreateRequestBase } from '../models/FormDefinitionCreateRequestBase'; +import { HubSpotFormDefinition } from '../models/HubSpotFormDefinition'; +import { HubSpotFormDefinitionPatchRequest } from '../models/HubSpotFormDefinitionPatchRequest'; + +/** + * no description + */ +export class FormsApiRequestFactory extends BaseAPIRequestFactory { + + /** + * Archive a form definition. New submissions will not be accepted and the form definition will be permanently deleted after 3 months. + * Archive a form definition + * @param formId The ID of the form to archive. + */ + public async archive(formId: string, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'formId' is not null or undefined + if (formId === null || formId === undefined) { + throw new RequiredError("FormsApi", "archive", "formId"); + } + + + // Path Params + const localVarPath = '/marketing/v3/forms/{formId}' + .replace('{' + 'formId' + '}', encodeURIComponent(String(formId))); + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + let authMethod: SecurityAuthentication | undefined; + // Apply auth methods + authMethod = _config.authMethods["oauth2"] + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Add a new `hubspot` form + * Create a form + * @param formDefinitionCreateRequestBase + */ + public async create(formDefinitionCreateRequestBase: FormDefinitionCreateRequestBase, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'formDefinitionCreateRequestBase' is not null or undefined + if (formDefinitionCreateRequestBase === null || formDefinitionCreateRequestBase === undefined) { + throw new RequiredError("FormsApi", "create", "formDefinitionCreateRequestBase"); + } + + + // Path Params + const localVarPath = '/marketing/v3/forms/'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(formDefinitionCreateRequestBase, "FormDefinitionCreateRequestBase", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod: SecurityAuthentication | undefined; + // Apply auth methods + authMethod = _config.authMethods["oauth2"] + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Returns a form based on the form ID provided. + * Get a form definition + * @param formId The unique identifier of the form + * @param archived Whether to return only results that have been archived. + */ + public async getById(formId: string, archived?: boolean, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'formId' is not null or undefined + if (formId === null || formId === undefined) { + throw new RequiredError("FormsApi", "getById", "formId"); + } + + + + // Path Params + const localVarPath = '/marketing/v3/forms/{formId}' + .replace('{' + 'formId' + '}', encodeURIComponent(String(formId))); + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + if (archived !== undefined) { + requestContext.setQueryParam("archived", ObjectSerializer.serialize(archived, "boolean", "")); + } + + + let authMethod: SecurityAuthentication | undefined; + // Apply auth methods + authMethod = _config.authMethods["oauth2"] + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Returns a list of forms based on the search filters. By default, it returns the first 20 `hubspot` forms + * Get a list of forms + * @param after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. + * @param limit The maximum number of results to display per page. + * @param archived Whether to return only results that have been archived. + * @param formTypes The form types to be included in the results. + */ + public async getPage(after?: string, limit?: number, archived?: boolean, formTypes?: Array<'hubspot' | 'captured' | 'flow' | 'blog_comment' | 'all'>, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + + + + + // Path Params + const localVarPath = '/marketing/v3/forms/'; + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + // Query Params + if (after !== undefined) { + requestContext.setQueryParam("after", ObjectSerializer.serialize(after, "string", "")); + } + + // Query Params + if (limit !== undefined) { + requestContext.setQueryParam("limit", ObjectSerializer.serialize(limit, "number", "int32")); + } + + // Query Params + if (archived !== undefined) { + requestContext.setQueryParam("archived", ObjectSerializer.serialize(archived, "boolean", "")); + } + + // Query Params + if (formTypes !== undefined) { + requestContext.setQueryParam("formTypes", ObjectSerializer.serialize(formTypes, "Array<'hubspot' | 'captured' | 'flow' | 'blog_comment' | 'all'>", "")); + } + + + let authMethod: SecurityAuthentication | undefined; + // Apply auth methods + authMethod = _config.authMethods["oauth2"] + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Update all fields of a hubspot form definition. + * Update a form definition + * @param formId + * @param hubSpotFormDefinition + */ + public async replace(formId: string, hubSpotFormDefinition: HubSpotFormDefinition, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'formId' is not null or undefined + if (formId === null || formId === undefined) { + throw new RequiredError("FormsApi", "replace", "formId"); + } + + + // verify required parameter 'hubSpotFormDefinition' is not null or undefined + if (hubSpotFormDefinition === null || hubSpotFormDefinition === undefined) { + throw new RequiredError("FormsApi", "replace", "hubSpotFormDefinition"); + } + + + // Path Params + const localVarPath = '/marketing/v3/forms/{formId}' + .replace('{' + 'formId' + '}', encodeURIComponent(String(formId))); + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(hubSpotFormDefinition, "HubSpotFormDefinition", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod: SecurityAuthentication | undefined; + // Apply auth methods + authMethod = _config.authMethods["oauth2"] + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + + /** + * Update some of the form definition components + * Partially update a form definition + * @param formId The ID of the form to update. + * @param hubSpotFormDefinitionPatchRequest + */ + public async update(formId: string, hubSpotFormDefinitionPatchRequest: HubSpotFormDefinitionPatchRequest, _options?: Configuration): Promise { + let _config = _options || this.configuration; + + // verify required parameter 'formId' is not null or undefined + if (formId === null || formId === undefined) { + throw new RequiredError("FormsApi", "update", "formId"); + } + + + // verify required parameter 'hubSpotFormDefinitionPatchRequest' is not null or undefined + if (hubSpotFormDefinitionPatchRequest === null || hubSpotFormDefinitionPatchRequest === undefined) { + throw new RequiredError("FormsApi", "update", "hubSpotFormDefinitionPatchRequest"); + } + + + // Path Params + const localVarPath = '/marketing/v3/forms/{formId}' + .replace('{' + 'formId' + '}', encodeURIComponent(String(formId))); + + // Make Request Context + const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.PATCH); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8") + + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json" + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(hubSpotFormDefinitionPatchRequest, "HubSpotFormDefinitionPatchRequest", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod: SecurityAuthentication | undefined; + // Apply auth methods + authMethod = _config.authMethods["oauth2"] + if (authMethod?.applySecurityAuthentication) { + await authMethod?.applySecurityAuthentication(requestContext); + } + + const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default + if (defaultAuth?.applySecurityAuthentication) { + await defaultAuth?.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + +} + +export class FormsApiResponseProcessor { + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to archive + * @throws ApiException if the response code was not in [200, 299] + */ + public async archive(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("204", response.httpStatusCode)) { + return; + } + if (isCodeInRange("0", response.httpStatusCode)) { + const body: Error = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Error", "" + ) as Error; + throw new ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: void = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "void", "" + ) as void; + return body; + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to create + * @throws ApiException if the response code was not in [200, 299] + */ + public async create(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("201", response.httpStatusCode)) { + const body: FormDefinitionBase = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "FormDefinitionBase", "" + ) as FormDefinitionBase; + return body; + } + if (isCodeInRange("0", response.httpStatusCode)) { + const body: Error = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Error", "" + ) as Error; + throw new ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: FormDefinitionBase = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "FormDefinitionBase", "" + ) as FormDefinitionBase; + return body; + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getById + * @throws ApiException if the response code was not in [200, 299] + */ + public async getById(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: FormDefinitionBase = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "FormDefinitionBase", "" + ) as FormDefinitionBase; + return body; + } + if (isCodeInRange("0", response.httpStatusCode)) { + const body: Error = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Error", "" + ) as Error; + throw new ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: FormDefinitionBase = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "FormDefinitionBase", "" + ) as FormDefinitionBase; + return body; + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to getPage + * @throws ApiException if the response code was not in [200, 299] + */ + public async getPage(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: CollectionResponseFormDefinitionBaseForwardPaging = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "CollectionResponseFormDefinitionBaseForwardPaging", "" + ) as CollectionResponseFormDefinitionBaseForwardPaging; + return body; + } + if (isCodeInRange("0", response.httpStatusCode)) { + const body: Error = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Error", "" + ) as Error; + throw new ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: CollectionResponseFormDefinitionBaseForwardPaging = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "CollectionResponseFormDefinitionBaseForwardPaging", "" + ) as CollectionResponseFormDefinitionBaseForwardPaging; + return body; + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to replace + * @throws ApiException if the response code was not in [200, 299] + */ + public async replace(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: FormDefinitionBase = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "FormDefinitionBase", "" + ) as FormDefinitionBase; + return body; + } + if (isCodeInRange("0", response.httpStatusCode)) { + const body: Error = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Error", "" + ) as Error; + throw new ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: FormDefinitionBase = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "FormDefinitionBase", "" + ) as FormDefinitionBase; + return body; + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to update + * @throws ApiException if the response code was not in [200, 299] + */ + public async update(response: ResponseContext): Promise { + const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: FormDefinitionBase = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "FormDefinitionBase", "" + ) as FormDefinitionBase; + return body; + } + if (isCodeInRange("0", response.httpStatusCode)) { + const body: Error = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "Error", "" + ) as Error; + throw new ApiException(response.httpStatusCode, "An error occurred.", body, response.headers); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: FormDefinitionBase = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "FormDefinitionBase", "" + ) as FormDefinitionBase; + return body; + } + + throw new ApiException(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers); + } + +} diff --git a/codegen/marketing/forms/apis/baseapi.ts b/codegen/marketing/forms/apis/baseapi.ts new file mode 100644 index 000000000..ce1e2dbc4 --- /dev/null +++ b/codegen/marketing/forms/apis/baseapi.ts @@ -0,0 +1,37 @@ +import { Configuration } from '../configuration' + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPIRequestFactory { + + constructor(protected configuration: Configuration) { + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public api: string, public method: string, public field: string) { + super("Required parameter " + field + " was null or undefined when calling " + api + "." + method + "."); + } +} diff --git a/codegen/marketing/forms/apis/exception.ts b/codegen/marketing/forms/apis/exception.ts new file mode 100644 index 000000000..9365d33a8 --- /dev/null +++ b/codegen/marketing/forms/apis/exception.ts @@ -0,0 +1,15 @@ +/** + * Represents an error caused by an api call i.e. it has attributes for a HTTP status code + * and the returned body object. + * + * Example + * API returns a ErrorMessageObject whenever HTTP status code is not in [200, 299] + * => ApiException(404, someErrorMessageObject) + * + */ +export class ApiException extends Error { + public constructor(public code: number, message: string, public body: T, public headers: { [key: string]: string; }) { + super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body) + "\nHeaders: " + + JSON.stringify(headers)) + } +} diff --git a/codegen/marketing/forms/auth/auth.ts b/codegen/marketing/forms/auth/auth.ts new file mode 100644 index 000000000..2bd763b1a --- /dev/null +++ b/codegen/marketing/forms/auth/auth.ts @@ -0,0 +1,79 @@ +import { RequestContext } from "../http/http"; + +/** + * Interface authentication schemes. + */ +export interface SecurityAuthentication { + /* + * @return returns the name of the security authentication as specified in OAI + */ + getName(): string; + + /** + * Applies the authentication scheme to the request context + * + * @params context the request context which should use this authentication scheme + */ + applySecurityAuthentication(context: RequestContext): void | Promise; +} + +export interface TokenProvider { + getToken(): Promise | string; +} + +/** + * Applies oauth2 authentication to the request context. + */ +export class Oauth2Authentication implements SecurityAuthentication { + /** + * Configures OAuth2 with the necessary properties + * + * @param accessToken: The access token to be used for every request + */ + public constructor(private accessToken: string) {} + + public getName(): string { + return "oauth2"; + } + + public applySecurityAuthentication(context: RequestContext) { + context.setHeaderParam("Authorization", "Bearer " + this.accessToken); + } +} + + +export type AuthMethods = { + "default"?: SecurityAuthentication, + "oauth2"?: SecurityAuthentication +} + +export type ApiKeyConfiguration = string; +export type HttpBasicConfiguration = { "username": string, "password": string }; +export type HttpBearerConfiguration = { tokenProvider: TokenProvider }; +export type OAuth2Configuration = { accessToken: string }; + +export type AuthMethodsConfiguration = { + "default"?: SecurityAuthentication, + "oauth2"?: OAuth2Configuration +} + +/** + * Creates the authentication methods from a swagger description. + * + */ +export function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods { + let authMethods: AuthMethods = {} + + if (!config) { + return authMethods; + } + authMethods["default"] = config["default"] + + if (config["oauth2"]) { + authMethods["oauth2"] = new Oauth2Authentication( + config["oauth2"]["accessToken"] + ); + } + + return authMethods; +} \ No newline at end of file diff --git a/codegen/marketing/forms/configuration.ts b/codegen/marketing/forms/configuration.ts new file mode 100644 index 000000000..7acb56e66 --- /dev/null +++ b/codegen/marketing/forms/configuration.ts @@ -0,0 +1,82 @@ +import { HttpLibrary } from "./http/http"; +import { Middleware, PromiseMiddleware, PromiseMiddlewareWrapper } from "./middleware"; +import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "./http/isomorphic-fetch"; +import { BaseServerConfiguration, server1 } from "./servers"; +import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth/auth"; + +export interface Configuration { + readonly baseServer: BaseServerConfiguration; + readonly httpApi: HttpLibrary; + readonly middleware: Middleware[]; + readonly authMethods: AuthMethods; +} + + +/** + * Interface with which a configuration object can be configured. + */ +export interface ConfigurationParameters { + /** + * Default server to use - a list of available servers (according to the + * OpenAPI yaml definition) is included in the `servers` const in `./servers`. You can also + * create your own server with the `ServerConfiguration` class from the same + * file. + */ + baseServer?: BaseServerConfiguration; + /** + * HTTP library to use e.g. IsomorphicFetch. This can usually be skipped as + * all generators come with a default library. + * If available, additional libraries can be imported from `./http/*` + */ + httpApi?: HttpLibrary; + + /** + * The middlewares which will be applied to requests and responses. You can + * add any number of middleware components to modify requests before they + * are sent or before they are deserialized by implementing the `Middleware` + * interface defined in `./middleware` + */ + middleware?: Middleware[]; + /** + * Configures middleware functions that return promises instead of + * Observables (which are used by `middleware`). Otherwise allows for the + * same functionality as `middleware`, i.e., modifying requests before they + * are sent and before they are deserialized. + */ + promiseMiddleware?: PromiseMiddleware[]; + /** + * Configuration for the available authentication methods (e.g., api keys) + * according to the OpenAPI yaml definition. For the definition, please refer to + * `./auth/auth` + */ + authMethods?: AuthMethodsConfiguration +} + +/** + * Provide your `ConfigurationParameters` to this function to get a `Configuration` + * object that can be used to configure your APIs (in the constructor or + * for each request individually). + * + * If a property is not included in conf, a default is used: + * - baseServer: server1 + * - httpApi: IsomorphicFetchHttpLibrary + * - middleware: [] + * - promiseMiddleware: [] + * - authMethods: {} + * + * @param conf partial configuration + */ +export function createConfiguration(conf: ConfigurationParameters = {}): Configuration { + const configuration: Configuration = { + baseServer: conf.baseServer !== undefined ? conf.baseServer : server1, + httpApi: conf.httpApi || new DefaultHttpLibrary(), + middleware: conf.middleware || [], + authMethods: configureAuthMethods(conf.authMethods) + }; + if (conf.promiseMiddleware) { + conf.promiseMiddleware.forEach( + m => configuration.middleware.push(new PromiseMiddlewareWrapper(m)) + ); + } + return configuration; +} \ No newline at end of file diff --git a/codegen/marketing/forms/http/http.ts b/codegen/marketing/forms/http/http.ts new file mode 100644 index 000000000..882e6c340 --- /dev/null +++ b/codegen/marketing/forms/http/http.ts @@ -0,0 +1,229 @@ +// TODO: evaluate if we can easily get rid of this library +import FormData from "form-data"; +import { URL, URLSearchParams } from 'url'; +import * as http from 'http'; +import * as https from 'https'; +import { Observable, from } from '../rxjsStub'; + +export * from './isomorphic-fetch'; + +/** + * Represents an HTTP method. + */ +export enum HttpMethod { + GET = "GET", + HEAD = "HEAD", + POST = "POST", + PUT = "PUT", + DELETE = "DELETE", + CONNECT = "CONNECT", + OPTIONS = "OPTIONS", + TRACE = "TRACE", + PATCH = "PATCH" +} + +/** + * Represents an HTTP file which will be transferred from or to a server. + */ +export type HttpFile = { + data: Buffer, + name: string +}; + +export class HttpException extends Error { + public constructor(msg: string) { + super(msg); + } +} + +/** + * Represents the body of an outgoing HTTP request. + */ +export type RequestBody = undefined | string | FormData | URLSearchParams; + +/** + * Represents an HTTP request context + */ +export class RequestContext { + private headers: { [key: string]: string } = {}; + private body: RequestBody = undefined; + private url: URL; + private agent: http.Agent | https.Agent | undefined = undefined; + + /** + * Creates the request context using a http method and request resource url + * + * @param url url of the requested resource + * @param httpMethod http method + */ + public constructor(url: string, private httpMethod: HttpMethod) { + this.url = new URL(url); + } + + /* + * Returns the url set in the constructor including the query string + * + */ + public getUrl(): string { + return this.url.toString().endsWith("/") ? + this.url.toString().slice(0, -1) + : this.url.toString(); + } + + /** + * Replaces the url set in the constructor with this url. + * + */ + public setUrl(url: string) { + this.url = new URL(url); + } + + /** + * Sets the body of the http request either as a string or FormData + * + * Note that setting a body on a HTTP GET, HEAD, DELETE, CONNECT or TRACE + * request is discouraged. + * https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#rfc.section.7.3.1 + * + * @param body the body of the request + */ + public setBody(body: RequestBody) { + this.body = body; + } + + public getHttpMethod(): HttpMethod { + return this.httpMethod; + } + + public getHeaders(): { [key: string]: string } { + return this.headers; + } + + public getBody(): RequestBody { + return this.body; + } + + public setQueryParam(name: string, value: string) { + this.url.searchParams.set(name, value); + } + + /** + * Sets a cookie with the name and value. NO check for duplicate cookies is performed + * + */ + public addCookie(name: string, value: string): void { + if (!this.headers["Cookie"]) { + this.headers["Cookie"] = ""; + } + this.headers["Cookie"] += name + "=" + value + "; "; + } + + public setHeaderParam(key: string, value: string): void { + this.headers[key] = value; + } + + public setAgent(agent: http.Agent | https.Agent) { + this.agent = agent; + } + + public getAgent(): http.Agent | https.Agent | undefined { + return this.agent; + } +} + +export interface ResponseBody { + text(): Promise; + binary(): Promise; +} + +/** + * Helper class to generate a `ResponseBody` from binary data + */ +export class SelfDecodingBody implements ResponseBody { + constructor(private dataSource: Promise) {} + + binary(): Promise { + return this.dataSource; + } + + async text(): Promise { + const data: Buffer = await this.dataSource; + return data.toString(); + } +} + +export class ResponseContext { + public constructor( + public httpStatusCode: number, + public headers: { [key: string]: string }, + public body: ResponseBody + ) {} + + /** + * Parse header value in the form `value; param1="value1"` + * + * E.g. for Content-Type or Content-Disposition + * Parameter names are converted to lower case + * The first parameter is returned with the key `""` + */ + public getParsedHeader(headerName: string): { [parameter: string]: string } { + const result: { [parameter: string]: string } = {}; + if (!this.headers[headerName]) { + return result; + } + + const parameters = this.headers[headerName].split(";"); + for (const parameter of parameters) { + let [key, value] = parameter.split("=", 2); + key = key.toLowerCase().trim(); + if (value === undefined) { + result[""] = key; + } else { + value = value.trim(); + if (value.startsWith('"') && value.endsWith('"')) { + value = value.substring(1, value.length - 1); + } + result[key] = value; + } + } + return result; + } + + public async getBodyAsFile(): Promise { + const data = await this.body.binary(); + const fileName = this.getParsedHeader("content-disposition")["filename"] || ""; + return { data, name: fileName }; + } + + /** + * Use a heuristic to get a body of unknown data structure. + * Return as string if possible, otherwise as binary. + */ + public getBodyAsAny(): Promise { + try { + return this.body.text(); + } catch {} + + try { + return this.body.binary(); + } catch {} + + return Promise.resolve(undefined); + } +} + +export interface HttpLibrary { + send(request: RequestContext): Observable; +} + +export interface PromiseHttpLibrary { + send(request: RequestContext): Promise; +} + +export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLibrary { + return { + send(request: RequestContext): Observable { + return from(promiseHttpLibrary.send(request)); + } + } +} diff --git a/codegen/marketing/forms/http/isomorphic-fetch.ts b/codegen/marketing/forms/http/isomorphic-fetch.ts new file mode 100644 index 000000000..26d267cfc --- /dev/null +++ b/codegen/marketing/forms/http/isomorphic-fetch.ts @@ -0,0 +1,32 @@ +import {HttpLibrary, RequestContext, ResponseContext} from './http'; +import { from, Observable } from '../rxjsStub'; +import fetch from "node-fetch"; + +export class IsomorphicFetchHttpLibrary implements HttpLibrary { + + public send(request: RequestContext): Observable { + let method = request.getHttpMethod().toString(); + let body = request.getBody(); + + const resultPromise = fetch(request.getUrl(), { + method: method, + body: body as any, + headers: request.getHeaders(), + agent: request.getAgent(), + }).then((resp: any) => { + const headers: { [name: string]: string } = {}; + resp.headers.forEach((value: string, name: string) => { + headers[name] = value; + }); + + const body = { + text: () => resp.text(), + binary: () => resp.buffer() + }; + return new ResponseContext(resp.status, headers, body); + }); + + return from>(resultPromise); + + } +} diff --git a/codegen/marketing/forms/index.ts b/codegen/marketing/forms/index.ts new file mode 100644 index 000000000..1bb8c50cd --- /dev/null +++ b/codegen/marketing/forms/index.ts @@ -0,0 +1,12 @@ +export * from "./http/http"; +export * from "./auth/auth"; +export * from "./models/all"; +export { createConfiguration } from "./configuration" +export { Configuration } from "./configuration" +export * from "./apis/exception"; +export * from "./servers"; +export { RequiredError } from "./apis/baseapi"; + +export { PromiseMiddleware as Middleware } from './middleware'; +export { PromiseFormsApi as FormsApi } from './types/PromiseAPI'; + diff --git a/codegen/marketing/forms/middleware.ts b/codegen/marketing/forms/middleware.ts new file mode 100644 index 000000000..524f93f01 --- /dev/null +++ b/codegen/marketing/forms/middleware.ts @@ -0,0 +1,66 @@ +import {RequestContext, ResponseContext} from './http/http'; +import { Observable, from } from './rxjsStub'; + +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ +export interface Middleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ + pre(context: RequestContext): Observable; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ + post(context: ResponseContext): Observable; +} + +export class PromiseMiddlewareWrapper implements Middleware { + + public constructor(private middleware: PromiseMiddleware) { + + } + + pre(context: RequestContext): Observable { + return from(this.middleware.pre(context)); + } + + post(context: ResponseContext): Observable { + return from(this.middleware.post(context)); + } + +} + +/** + * Defines the contract for a middleware intercepting requests before + * they are sent (but after the RequestContext was created) + * and before the ResponseContext is unwrapped. + * + */ +export interface PromiseMiddleware { + /** + * Modifies the request before the request is sent. + * + * @param context RequestContext of a request which is about to be sent to the server + * @returns an observable of the updated request context + * + */ + pre(context: RequestContext): Promise; + /** + * Modifies the returned response before it is deserialized. + * + * @param context ResponseContext of a sent request + * @returns an observable of the modified response context + */ + post(context: ResponseContext): Promise; +} diff --git a/codegen/marketing/forms/models/CollectionResponseFormDefinitionBaseForwardPaging.ts b/codegen/marketing/forms/models/CollectionResponseFormDefinitionBaseForwardPaging.ts new file mode 100644 index 000000000..012e0769e --- /dev/null +++ b/codegen/marketing/forms/models/CollectionResponseFormDefinitionBaseForwardPaging.ts @@ -0,0 +1,44 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { CollectionResponseFormDefinitionBaseForwardPagingResultsInner } from '../models/CollectionResponseFormDefinitionBaseForwardPagingResultsInner'; +import { ForwardPaging } from '../models/ForwardPaging'; +import { HttpFile } from '../http/http'; + +export class CollectionResponseFormDefinitionBaseForwardPaging { + 'paging'?: ForwardPaging; + 'results': Array; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "paging", + "baseName": "paging", + "type": "ForwardPaging", + "format": "" + }, + { + "name": "results", + "baseName": "results", + "type": "Array", + "format": "" + } ]; + + static getAttributeTypeMap() { + return CollectionResponseFormDefinitionBaseForwardPaging.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/codegen/marketing/forms/models/CollectionResponseFormDefinitionBaseForwardPagingResultsInner.ts b/codegen/marketing/forms/models/CollectionResponseFormDefinitionBaseForwardPagingResultsInner.ts new file mode 100644 index 000000000..4d7f03350 --- /dev/null +++ b/codegen/marketing/forms/models/CollectionResponseFormDefinitionBaseForwardPagingResultsInner.ts @@ -0,0 +1,112 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { FieldGroup } from '../models/FieldGroup'; +import { FormDisplayOptions } from '../models/FormDisplayOptions'; +import { HubSpotFormConfiguration } from '../models/HubSpotFormConfiguration'; +import { HubSpotFormDefinition } from '../models/HubSpotFormDefinition'; +import { HttpFile } from '../http/http'; + +export class CollectionResponseFormDefinitionBaseForwardPagingResultsInner { + 'formType': CollectionResponseFormDefinitionBaseForwardPagingResultsInnerFormTypeEnum; + 'id': string; + 'name': string; + 'createdAt': Date; + 'updatedAt': Date; + 'archived': boolean; + 'archivedAt'?: Date; + 'fieldGroups': Array; + 'configuration': HubSpotFormConfiguration; + 'displayOptions': FormDisplayOptions; + 'legalConsentOptions': any; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "formType", + "baseName": "formType", + "type": "CollectionResponseFormDefinitionBaseForwardPagingResultsInnerFormTypeEnum", + "format": "" + }, + { + "name": "id", + "baseName": "id", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "createdAt", + "baseName": "createdAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "updatedAt", + "baseName": "updatedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "archived", + "baseName": "archived", + "type": "boolean", + "format": "" + }, + { + "name": "archivedAt", + "baseName": "archivedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "fieldGroups", + "baseName": "fieldGroups", + "type": "Array", + "format": "" + }, + { + "name": "configuration", + "baseName": "configuration", + "type": "HubSpotFormConfiguration", + "format": "" + }, + { + "name": "displayOptions", + "baseName": "displayOptions", + "type": "FormDisplayOptions", + "format": "" + }, + { + "name": "legalConsentOptions", + "baseName": "legalConsentOptions", + "type": "any", + "format": "" + } ]; + + static getAttributeTypeMap() { + return CollectionResponseFormDefinitionBaseForwardPagingResultsInner.attributeTypeMap; + } + + public constructor() { + } +} + + +export type CollectionResponseFormDefinitionBaseForwardPagingResultsInnerFormTypeEnum = "hubspot" ; + diff --git a/codegen/marketing/forms/models/DatepickerField.ts b/codegen/marketing/forms/models/DatepickerField.ts new file mode 100644 index 000000000..49e7a4df4 --- /dev/null +++ b/codegen/marketing/forms/models/DatepickerField.ts @@ -0,0 +1,135 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { HttpFile } from '../http/http'; + +/** +* A form field used to select a date +*/ +export class DatepickerField { + /** + * Determines how the field will be displayed and validated. + */ + 'fieldType': DatepickerFieldFieldTypeEnum; + /** + * A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1. + */ + 'objectTypeId': string; + /** + * The identifier of the field. In combination with the object type ID, it must be unique. + */ + 'name': string; + /** + * The main label for the form field. + */ + 'label': string; + /** + * Additional text helping the customer to complete the field. + */ + 'description'?: string; + /** + * Whether a value for this field is required when submitting the form. + */ + 'required': boolean; + /** + * Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in. + */ + 'hidden': boolean; + /** + * A list of other fields to make visible based on the value filled in for this field. + */ + 'dependentFields': Array; + /** + * The prompt text showing when the field isn't filled in. + */ + 'placeholder'?: string; + /** + * The value filled in by default. This value will be submitted unless the customer modifies it. + */ + 'defaultValue'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "DatepickerFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "placeholder", + "baseName": "placeholder", + "type": "string", + "format": "" + }, + { + "name": "defaultValue", + "baseName": "defaultValue", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return DatepickerField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type DatepickerFieldFieldTypeEnum = "datepicker" ; + diff --git a/codegen/marketing/forms/models/DependentField.ts b/codegen/marketing/forms/models/DependentField.ts new file mode 100644 index 000000000..2de22e427 --- /dev/null +++ b/codegen/marketing/forms/models/DependentField.ts @@ -0,0 +1,47 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentFieldDependentField } from '../models/DependentFieldDependentField'; +import { DependentFieldFilter } from '../models/DependentFieldFilter'; +import { HttpFile } from '../http/http'; + +/** +* A form field that will be displayed based on what the customer entered in another field. +*/ +export class DependentField { + 'dependentCondition': DependentFieldFilter; + 'dependentField': DependentFieldDependentField; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "dependentCondition", + "baseName": "dependentCondition", + "type": "DependentFieldFilter", + "format": "" + }, + { + "name": "dependentField", + "baseName": "dependentField", + "type": "DependentFieldDependentField", + "format": "" + } ]; + + static getAttributeTypeMap() { + return DependentField.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/codegen/marketing/forms/models/DependentFieldDependentField.ts b/codegen/marketing/forms/models/DependentFieldDependentField.ts new file mode 100644 index 000000000..33d302f2f --- /dev/null +++ b/codegen/marketing/forms/models/DependentFieldDependentField.ts @@ -0,0 +1,164 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DatepickerField } from '../models/DatepickerField'; +import { DependentField } from '../models/DependentField'; +import { DropdownField } from '../models/DropdownField'; +import { EmailField } from '../models/EmailField'; +import { EnumeratedFieldOption } from '../models/EnumeratedFieldOption'; +import { FileField } from '../models/FileField'; +import { MobilePhoneField } from '../models/MobilePhoneField'; +import { MultiLineTextField } from '../models/MultiLineTextField'; +import { MultipleCheckboxesField } from '../models/MultipleCheckboxesField'; +import { NumberField } from '../models/NumberField'; +import { NumberFieldValidation } from '../models/NumberFieldValidation'; +import { PaymentLinkRadioField } from '../models/PaymentLinkRadioField'; +import { PhoneField } from '../models/PhoneField'; +import { RadioField } from '../models/RadioField'; +import { SingleCheckboxField } from '../models/SingleCheckboxField'; +import { SingleLineTextField } from '../models/SingleLineTextField'; +import { HttpFile } from '../http/http'; + +export class DependentFieldDependentField { + 'fieldType': DependentFieldDependentFieldFieldTypeEnum; + 'objectTypeId': string; + 'name': string; + 'label': string; + 'description'?: string; + 'required': boolean; + 'hidden': boolean; + 'dependentFields': Array; + /** + * The prompt text showing when the field isn't filled in. + */ + 'placeholder'?: string; + /** + * The value filled in by default. This value will be submitted unless the customer modifies it. + */ + 'defaultValue'?: string; + 'validation': NumberFieldValidation; + /** + * Whether to display a country code drop down next to the phone field. + */ + 'useCountryCodeSelect': boolean; + 'defaultValues': Array; + 'options': Array; + /** + * Whether to allow the upload of multiple files. + */ + 'allowMultipleFiles': boolean; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "DependentFieldDependentFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "placeholder", + "baseName": "placeholder", + "type": "string", + "format": "" + }, + { + "name": "defaultValue", + "baseName": "defaultValue", + "type": "string", + "format": "" + }, + { + "name": "validation", + "baseName": "validation", + "type": "NumberFieldValidation", + "format": "" + }, + { + "name": "useCountryCodeSelect", + "baseName": "useCountryCodeSelect", + "type": "boolean", + "format": "" + }, + { + "name": "defaultValues", + "baseName": "defaultValues", + "type": "Array", + "format": "" + }, + { + "name": "options", + "baseName": "options", + "type": "Array", + "format": "" + }, + { + "name": "allowMultipleFiles", + "baseName": "allowMultipleFiles", + "type": "boolean", + "format": "" + } ]; + + static getAttributeTypeMap() { + return DependentFieldDependentField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type DependentFieldDependentFieldFieldTypeEnum = "payment_link_radio" ; + diff --git a/codegen/marketing/forms/models/DependentFieldFilter.ts b/codegen/marketing/forms/models/DependentFieldFilter.ts new file mode 100644 index 000000000..27235790e --- /dev/null +++ b/codegen/marketing/forms/models/DependentFieldFilter.ts @@ -0,0 +1,69 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* A condition based on customer input +*/ +export class DependentFieldFilter { + 'operator': DependentFieldFilterOperatorEnum; + 'value': string; + 'values': Array; + 'rangeStart': string; + 'rangeEnd': string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "operator", + "baseName": "operator", + "type": "DependentFieldFilterOperatorEnum", + "format": "" + }, + { + "name": "value", + "baseName": "value", + "type": "string", + "format": "" + }, + { + "name": "values", + "baseName": "values", + "type": "Array", + "format": "" + }, + { + "name": "rangeStart", + "baseName": "rangeStart", + "type": "string", + "format": "" + }, + { + "name": "rangeEnd", + "baseName": "rangeEnd", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return DependentFieldFilter.attributeTypeMap; + } + + public constructor() { + } +} + + +export type DependentFieldFilterOperatorEnum = "eq" | "neq" | "contains" | "doesnt_contain" | "str_starts_with" | "str_ends_with" | "lt" | "lte" | "gt" | "gte" | "between" | "not_between" | "within_time_reverse" | "within_time" | "set_any" | "set_not_any" | "set_all" | "set_not_all" | "set_eq" | "set_neq" | "is_not_empty" ; + diff --git a/codegen/marketing/forms/models/DropdownField.ts b/codegen/marketing/forms/models/DropdownField.ts new file mode 100644 index 000000000..854036c7e --- /dev/null +++ b/codegen/marketing/forms/models/DropdownField.ts @@ -0,0 +1,146 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { EnumeratedFieldOption } from '../models/EnumeratedFieldOption'; +import { HttpFile } from '../http/http'; + +/** +* A field consisting of a drop down with multiple choices. +*/ +export class DropdownField { + /** + * Determines how the field will be displayed and validated. + */ + 'fieldType': DropdownFieldFieldTypeEnum; + /** + * A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1. + */ + 'objectTypeId': string; + /** + * The identifier of the field. In combination with the object type ID, it must be unique. + */ + 'name': string; + /** + * The main label for the form field. + */ + 'label': string; + /** + * Additional text helping the customer to complete the field. + */ + 'description'?: string; + /** + * Whether a value for this field is required when submitting the form. + */ + 'required': boolean; + /** + * Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in. + */ + 'hidden': boolean; + /** + * A list of other fields to make visible based on the value filled in for this field. + */ + 'dependentFields': Array; + /** + * The values selected by default. Those values will be submitted unless the customer modifies them. + */ + 'defaultValues': Array; + /** + * The list of available choices for this field. + */ + 'options': Array; + /** + * The prompt text showing when the field isn't filled in. + */ + 'placeholder'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "DropdownFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "defaultValues", + "baseName": "defaultValues", + "type": "Array", + "format": "" + }, + { + "name": "options", + "baseName": "options", + "type": "Array", + "format": "" + }, + { + "name": "placeholder", + "baseName": "placeholder", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return DropdownField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type DropdownFieldFieldTypeEnum = "dropdown" ; + diff --git a/codegen/marketing/forms/models/EmailField.ts b/codegen/marketing/forms/models/EmailField.ts new file mode 100644 index 000000000..1c46dc3a9 --- /dev/null +++ b/codegen/marketing/forms/models/EmailField.ts @@ -0,0 +1,143 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { EmailFieldValidation } from '../models/EmailFieldValidation'; +import { HttpFile } from '../http/http'; + +/** +* A form field used for collecting an email address. +*/ +export class EmailField { + /** + * Determines how the field will be displayed and validated. + */ + 'fieldType': EmailFieldFieldTypeEnum; + /** + * A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1. + */ + 'objectTypeId': string; + /** + * The identifier of the field. In combination with the object type ID, it must be unique. + */ + 'name': string; + /** + * The main label for the form field. + */ + 'label': string; + /** + * Additional text helping the customer to complete the field. + */ + 'description'?: string; + /** + * Whether a value for this field is required when submitting the form. + */ + 'required': boolean; + /** + * Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in. + */ + 'hidden': boolean; + /** + * A list of other fields to make visible based on the value filled in for this field. + */ + 'dependentFields': Array; + /** + * The prompt text showing when the field isn't filled in. + */ + 'placeholder'?: string; + /** + * The value filled in by default. This value will be submitted unless the customer modifies it. + */ + 'defaultValue'?: string; + 'validation': EmailFieldValidation; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "EmailFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "placeholder", + "baseName": "placeholder", + "type": "string", + "format": "" + }, + { + "name": "defaultValue", + "baseName": "defaultValue", + "type": "string", + "format": "" + }, + { + "name": "validation", + "baseName": "validation", + "type": "EmailFieldValidation", + "format": "" + } ]; + + static getAttributeTypeMap() { + return EmailField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type EmailFieldFieldTypeEnum = "email" ; + diff --git a/codegen/marketing/forms/models/EmailFieldValidation.ts b/codegen/marketing/forms/models/EmailFieldValidation.ts new file mode 100644 index 000000000..484e556a6 --- /dev/null +++ b/codegen/marketing/forms/models/EmailFieldValidation.ts @@ -0,0 +1,51 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* Describes how an email address should be validated. +*/ +export class EmailFieldValidation { + /** + * A list of email domains to block. + */ + 'blockedEmailDomains': Array; + /** + * Whether to block the free email providers. + */ + 'useDefaultBlockList': boolean; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "blockedEmailDomains", + "baseName": "blockedEmailDomains", + "type": "Array", + "format": "" + }, + { + "name": "useDefaultBlockList", + "baseName": "useDefaultBlockList", + "type": "boolean", + "format": "" + } ]; + + static getAttributeTypeMap() { + return EmailFieldValidation.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/codegen/marketing/forms/models/EnumeratedFieldOption.ts b/codegen/marketing/forms/models/EnumeratedFieldOption.ts new file mode 100644 index 000000000..4f4acc104 --- /dev/null +++ b/codegen/marketing/forms/models/EnumeratedFieldOption.ts @@ -0,0 +1,65 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class EnumeratedFieldOption { + /** + * The visible label for this choice. + */ + 'label': string; + /** + * The value which will be submitted if this choice is selected. + */ + 'value': string; + 'description'?: string; + /** + * The order the choices will be displayed in. + */ + 'displayOrder': number; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "value", + "baseName": "value", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "displayOrder", + "baseName": "displayOrder", + "type": "number", + "format": "int32" + } ]; + + static getAttributeTypeMap() { + return EnumeratedFieldOption.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/codegen/marketing/forms/models/ErrorDetail.ts b/codegen/marketing/forms/models/ErrorDetail.ts new file mode 100644 index 000000000..cd62636e2 --- /dev/null +++ b/codegen/marketing/forms/models/ErrorDetail.ts @@ -0,0 +1,78 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class ErrorDetail { + /** + * A specific category that contains more specific detail about the error + */ + 'subCategory'?: string; + /** + * The status code associated with the error detail + */ + 'code'?: string; + /** + * The name of the field or parameter in which the error was found. + */ + '_in'?: string; + /** + * Context about the error condition + */ + 'context'?: { [key: string]: Array; }; + /** + * A human readable message describing the error along with remediation steps where appropriate + */ + 'message': string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "subCategory", + "baseName": "subCategory", + "type": "string", + "format": "" + }, + { + "name": "code", + "baseName": "code", + "type": "string", + "format": "" + }, + { + "name": "_in", + "baseName": "in", + "type": "string", + "format": "" + }, + { + "name": "context", + "baseName": "context", + "type": "{ [key: string]: Array; }", + "format": "" + }, + { + "name": "message", + "baseName": "message", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ErrorDetail.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/codegen/marketing/forms/models/FieldGroup.ts b/codegen/marketing/forms/models/FieldGroup.ts new file mode 100644 index 000000000..eae883aee --- /dev/null +++ b/codegen/marketing/forms/models/FieldGroup.ts @@ -0,0 +1,76 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentFieldDependentField } from '../models/DependentFieldDependentField'; +import { HttpFile } from '../http/http'; + +/** +* A collection of up to three form fields usually displayed in a row. +*/ +export class FieldGroup { + /** + * + */ + 'groupType': FieldGroupGroupTypeEnum; + /** + * The type of rich text included. The default value is text. + */ + 'richTextType': FieldGroupRichTextTypeEnum; + /** + * A block of rich text or an image. Those can be used to add extra information for the customers filling in the form. If the field group includes fields, the rich text will be displayed before the fields. + */ + 'richText'?: string; + /** + * The form fields included in the group + */ + 'fields': Array; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "groupType", + "baseName": "groupType", + "type": "FieldGroupGroupTypeEnum", + "format": "" + }, + { + "name": "richTextType", + "baseName": "richTextType", + "type": "FieldGroupRichTextTypeEnum", + "format": "" + }, + { + "name": "richText", + "baseName": "richText", + "type": "string", + "format": "" + }, + { + "name": "fields", + "baseName": "fields", + "type": "Array", + "format": "" + } ]; + + static getAttributeTypeMap() { + return FieldGroup.attributeTypeMap; + } + + public constructor() { + } +} + + +export type FieldGroupGroupTypeEnum = "default_group" | "progressive" | "queued" ; +export type FieldGroupRichTextTypeEnum = "text" | "image" ; + diff --git a/codegen/marketing/forms/models/FileField.ts b/codegen/marketing/forms/models/FileField.ts new file mode 100644 index 000000000..10793e840 --- /dev/null +++ b/codegen/marketing/forms/models/FileField.ts @@ -0,0 +1,145 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { HttpFile } from '../http/http'; + +/** +* A form field used for uploading one or more files. +*/ +export class FileField { + /** + * Determines how the field will be displayed and validated. + */ + 'fieldType': FileFieldFieldTypeEnum; + /** + * A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1. + */ + 'objectTypeId': string; + /** + * The identifier of the field. In combination with the object type ID, it must be unique. + */ + 'name': string; + /** + * The main label for the form field. + */ + 'label': string; + /** + * Additional text helping the customer to complete the field. + */ + 'description'?: string; + /** + * Whether a value for this field is required when submitting the form. + */ + 'required': boolean; + /** + * Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in. + */ + 'hidden': boolean; + /** + * A list of other fields to make visible based on the value filled in for this field. + */ + 'dependentFields': Array; + /** + * The prompt text showing when the field isn't filled in. + */ + 'placeholder'?: string; + /** + * The value filled in by default. This value will be submitted unless the customer modifies it. + */ + 'defaultValue'?: string; + /** + * Whether to allow the upload of multiple files. + */ + 'allowMultipleFiles': boolean; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "FileFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "placeholder", + "baseName": "placeholder", + "type": "string", + "format": "" + }, + { + "name": "defaultValue", + "baseName": "defaultValue", + "type": "string", + "format": "" + }, + { + "name": "allowMultipleFiles", + "baseName": "allowMultipleFiles", + "type": "boolean", + "format": "" + } ]; + + static getAttributeTypeMap() { + return FileField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type FileFieldFieldTypeEnum = "file" ; + diff --git a/codegen/marketing/forms/models/FormDefinitionBase.ts b/codegen/marketing/forms/models/FormDefinitionBase.ts new file mode 100644 index 000000000..0cf6ab95d --- /dev/null +++ b/codegen/marketing/forms/models/FormDefinitionBase.ts @@ -0,0 +1,112 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { FieldGroup } from '../models/FieldGroup'; +import { FormDisplayOptions } from '../models/FormDisplayOptions'; +import { HubSpotFormConfiguration } from '../models/HubSpotFormConfiguration'; +import { HubSpotFormDefinition } from '../models/HubSpotFormDefinition'; +import { HttpFile } from '../http/http'; + +export class FormDefinitionBase { + 'formType': FormDefinitionBaseFormTypeEnum; + 'id': string; + 'name': string; + 'createdAt': Date; + 'updatedAt': Date; + 'archived': boolean; + 'archivedAt'?: Date; + 'fieldGroups': Array; + 'configuration': HubSpotFormConfiguration; + 'displayOptions': FormDisplayOptions; + 'legalConsentOptions': any; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "formType", + "baseName": "formType", + "type": "FormDefinitionBaseFormTypeEnum", + "format": "" + }, + { + "name": "id", + "baseName": "id", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "createdAt", + "baseName": "createdAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "updatedAt", + "baseName": "updatedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "archived", + "baseName": "archived", + "type": "boolean", + "format": "" + }, + { + "name": "archivedAt", + "baseName": "archivedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "fieldGroups", + "baseName": "fieldGroups", + "type": "Array", + "format": "" + }, + { + "name": "configuration", + "baseName": "configuration", + "type": "HubSpotFormConfiguration", + "format": "" + }, + { + "name": "displayOptions", + "baseName": "displayOptions", + "type": "FormDisplayOptions", + "format": "" + }, + { + "name": "legalConsentOptions", + "baseName": "legalConsentOptions", + "type": "any", + "format": "" + } ]; + + static getAttributeTypeMap() { + return FormDefinitionBase.attributeTypeMap; + } + + public constructor() { + } +} + + +export type FormDefinitionBaseFormTypeEnum = "hubspot" ; + diff --git a/codegen/marketing/forms/models/FormDefinitionCreateRequestBase.ts b/codegen/marketing/forms/models/FormDefinitionCreateRequestBase.ts new file mode 100644 index 000000000..9f25d9906 --- /dev/null +++ b/codegen/marketing/forms/models/FormDefinitionCreateRequestBase.ts @@ -0,0 +1,105 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { FieldGroup } from '../models/FieldGroup'; +import { FormDisplayOptions } from '../models/FormDisplayOptions'; +import { HubSpotFormConfiguration } from '../models/HubSpotFormConfiguration'; +import { HubSpotFormDefinitionCreateRequest } from '../models/HubSpotFormDefinitionCreateRequest'; +import { HttpFile } from '../http/http'; + +export class FormDefinitionCreateRequestBase { + 'formType': FormDefinitionCreateRequestBaseFormTypeEnum; + 'name': string; + 'createdAt': Date; + 'updatedAt': Date; + 'archived': boolean; + 'archivedAt'?: Date; + 'fieldGroups': Array; + 'configuration': HubSpotFormConfiguration; + 'displayOptions': FormDisplayOptions; + 'legalConsentOptions': any; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "formType", + "baseName": "formType", + "type": "FormDefinitionCreateRequestBaseFormTypeEnum", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "createdAt", + "baseName": "createdAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "updatedAt", + "baseName": "updatedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "archived", + "baseName": "archived", + "type": "boolean", + "format": "" + }, + { + "name": "archivedAt", + "baseName": "archivedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "fieldGroups", + "baseName": "fieldGroups", + "type": "Array", + "format": "" + }, + { + "name": "configuration", + "baseName": "configuration", + "type": "HubSpotFormConfiguration", + "format": "" + }, + { + "name": "displayOptions", + "baseName": "displayOptions", + "type": "FormDisplayOptions", + "format": "" + }, + { + "name": "legalConsentOptions", + "baseName": "legalConsentOptions", + "type": "any", + "format": "" + } ]; + + static getAttributeTypeMap() { + return FormDefinitionCreateRequestBase.attributeTypeMap; + } + + public constructor() { + } +} + + +export type FormDefinitionCreateRequestBaseFormTypeEnum = "hubspot" ; + diff --git a/codegen/marketing/forms/models/FormDisplayOptions.ts b/codegen/marketing/forms/models/FormDisplayOptions.ts new file mode 100644 index 000000000..89f7edf7a --- /dev/null +++ b/codegen/marketing/forms/models/FormDisplayOptions.ts @@ -0,0 +1,82 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { FormStyle } from '../models/FormStyle'; +import { HttpFile } from '../http/http'; + +/** +* Options for styling the form. +*/ +export class FormDisplayOptions { + /** + * Whether the form will render as raw HTML as opposed to inside an iFrame. + */ + 'renderRawHtml': boolean; + /** + * + */ + 'cssClass'?: string; + /** + * The theme used for styling the input fields. This will not apply if the form is added to a HubSpot CMS page. + */ + 'theme': FormDisplayOptionsThemeEnum; + /** + * The text displayed on the form submit button. + */ + 'submitButtonText': string; + 'style': FormStyle; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "renderRawHtml", + "baseName": "renderRawHtml", + "type": "boolean", + "format": "" + }, + { + "name": "cssClass", + "baseName": "cssClass", + "type": "string", + "format": "" + }, + { + "name": "theme", + "baseName": "theme", + "type": "FormDisplayOptionsThemeEnum", + "format": "" + }, + { + "name": "submitButtonText", + "baseName": "submitButtonText", + "type": "string", + "format": "" + }, + { + "name": "style", + "baseName": "style", + "type": "FormStyle", + "format": "" + } ]; + + static getAttributeTypeMap() { + return FormDisplayOptions.attributeTypeMap; + } + + public constructor() { + } +} + + +export type FormDisplayOptionsThemeEnum = "default_style" | "canvas" | "linear" | "round" | "sharp" | "legacy" ; + diff --git a/codegen/marketing/forms/models/FormPostSubmitAction.ts b/codegen/marketing/forms/models/FormPostSubmitAction.ts new file mode 100644 index 000000000..4db117f0a --- /dev/null +++ b/codegen/marketing/forms/models/FormPostSubmitAction.ts @@ -0,0 +1,54 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* What should happen after the customer submits the form. +*/ +export class FormPostSubmitAction { + /** + * The action to take after submit. The default action is displaying a thank you message. + */ + 'type': FormPostSubmitActionTypeEnum; + /** + * The thank you text or the page to redirect to. + */ + 'value': string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "type", + "baseName": "type", + "type": "FormPostSubmitActionTypeEnum", + "format": "" + }, + { + "name": "value", + "baseName": "value", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return FormPostSubmitAction.attributeTypeMap; + } + + public constructor() { + } +} + + +export type FormPostSubmitActionTypeEnum = "thank_you" | "redirect_url" ; + diff --git a/codegen/marketing/forms/models/FormStyle.ts b/codegen/marketing/forms/models/FormStyle.ts new file mode 100644 index 000000000..f2c6ba0a8 --- /dev/null +++ b/codegen/marketing/forms/models/FormStyle.ts @@ -0,0 +1,154 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* Styling options for the form +*/ +export class FormStyle { + /** + * + */ + 'labelTextSize': string; + /** + * + */ + 'legalConsentTextColor': string; + /** + * + */ + 'fontFamily': string; + /** + * + */ + 'legalConsentTextSize': string; + /** + * + */ + 'backgroundWidth': string; + /** + * + */ + 'helpTextSize': string; + /** + * + */ + 'submitFontColor': string; + /** + * + */ + 'labelTextColor': string; + /** + * + */ + 'submitAlignment': FormStyleSubmitAlignmentEnum; + /** + * + */ + 'submitSize': string; + /** + * + */ + 'helpTextColor': string; + /** + * + */ + 'submitColor': string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "labelTextSize", + "baseName": "labelTextSize", + "type": "string", + "format": "" + }, + { + "name": "legalConsentTextColor", + "baseName": "legalConsentTextColor", + "type": "string", + "format": "" + }, + { + "name": "fontFamily", + "baseName": "fontFamily", + "type": "string", + "format": "" + }, + { + "name": "legalConsentTextSize", + "baseName": "legalConsentTextSize", + "type": "string", + "format": "" + }, + { + "name": "backgroundWidth", + "baseName": "backgroundWidth", + "type": "string", + "format": "" + }, + { + "name": "helpTextSize", + "baseName": "helpTextSize", + "type": "string", + "format": "" + }, + { + "name": "submitFontColor", + "baseName": "submitFontColor", + "type": "string", + "format": "" + }, + { + "name": "labelTextColor", + "baseName": "labelTextColor", + "type": "string", + "format": "" + }, + { + "name": "submitAlignment", + "baseName": "submitAlignment", + "type": "FormStyleSubmitAlignmentEnum", + "format": "" + }, + { + "name": "submitSize", + "baseName": "submitSize", + "type": "string", + "format": "" + }, + { + "name": "helpTextColor", + "baseName": "helpTextColor", + "type": "string", + "format": "" + }, + { + "name": "submitColor", + "baseName": "submitColor", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return FormStyle.attributeTypeMap; + } + + public constructor() { + } +} + + +export type FormStyleSubmitAlignmentEnum = "left" | "right" | "center" ; + diff --git a/codegen/marketing/forms/models/ForwardPaging.ts b/codegen/marketing/forms/models/ForwardPaging.ts new file mode 100644 index 000000000..344c6e81a --- /dev/null +++ b/codegen/marketing/forms/models/ForwardPaging.ts @@ -0,0 +1,36 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { NextPage } from '../models/NextPage'; +import { HttpFile } from '../http/http'; + +export class ForwardPaging { + 'next'?: NextPage; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "next", + "baseName": "next", + "type": "NextPage", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ForwardPaging.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/codegen/marketing/forms/models/HubSpotFormConfiguration.ts b/codegen/marketing/forms/models/HubSpotFormConfiguration.ts new file mode 100644 index 000000000..6317de708 --- /dev/null +++ b/codegen/marketing/forms/models/HubSpotFormConfiguration.ts @@ -0,0 +1,139 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { FormPostSubmitAction } from '../models/FormPostSubmitAction'; +import { HttpFile } from '../http/http'; + +export class HubSpotFormConfiguration { + /** + * Whether to create a new contact when a form is submitted with an email address that doesn’t match any in your existing contacts records. + */ + 'createNewContactForNewEmail': boolean; + /** + * Whether the form can be edited. + */ + 'editable': boolean; + /** + * Whether to add a reset link to the form. This removes any pre-populated content on the form and creates a new contact on submission. + */ + 'allowLinkToResetKnownValues': boolean; + 'postSubmitAction': FormPostSubmitAction; + /** + * The language of the form. + */ + 'language': HubSpotFormConfigurationLanguageEnum; + /** + * Whether contact fields should pre-populate with known information when a contact returns to your site. + */ + 'prePopulateKnownValues': boolean; + /** + * Whether the form can be cloned. + */ + 'cloneable': boolean; + /** + * Whether to send a notification email to the contact owner when a submission is received. + */ + 'notifyContactOwner': boolean; + /** + * Whether CAPTCHA (spam prevention) is enabled. + */ + 'recaptchaEnabled': boolean; + /** + * Whether the form can be archived. + */ + 'archivable': boolean; + /** + * The list of user IDs to receive a notification email when a submission is received. + */ + 'notifyRecipients': Array; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "createNewContactForNewEmail", + "baseName": "createNewContactForNewEmail", + "type": "boolean", + "format": "" + }, + { + "name": "editable", + "baseName": "editable", + "type": "boolean", + "format": "" + }, + { + "name": "allowLinkToResetKnownValues", + "baseName": "allowLinkToResetKnownValues", + "type": "boolean", + "format": "" + }, + { + "name": "postSubmitAction", + "baseName": "postSubmitAction", + "type": "FormPostSubmitAction", + "format": "" + }, + { + "name": "language", + "baseName": "language", + "type": "HubSpotFormConfigurationLanguageEnum", + "format": "" + }, + { + "name": "prePopulateKnownValues", + "baseName": "prePopulateKnownValues", + "type": "boolean", + "format": "" + }, + { + "name": "cloneable", + "baseName": "cloneable", + "type": "boolean", + "format": "" + }, + { + "name": "notifyContactOwner", + "baseName": "notifyContactOwner", + "type": "boolean", + "format": "" + }, + { + "name": "recaptchaEnabled", + "baseName": "recaptchaEnabled", + "type": "boolean", + "format": "" + }, + { + "name": "archivable", + "baseName": "archivable", + "type": "boolean", + "format": "" + }, + { + "name": "notifyRecipients", + "baseName": "notifyRecipients", + "type": "Array", + "format": "" + } ]; + + static getAttributeTypeMap() { + return HubSpotFormConfiguration.attributeTypeMap; + } + + public constructor() { + } +} + + +export type HubSpotFormConfigurationLanguageEnum = "af" | "ar-eg" | "bg" | "bn" | "ca-es" | "cs" | "da" | "de" | "el" | "en" | "es" | "es-mx" | "fi" | "fr" | "fr-ca" | "he-il" | "hr" | "hu" | "id" | "it" | "ja" | "ko" | "lt" | "ms" | "nl" | "no-no" | "pl" | "pt" | "pt-br" | "ro" | "ru" | "sk" | "sl" | "sv" | "th" | "tl" | "tr" | "uk" | "vi" | "zh-cn" | "zh-hk" | "zh-tw" ; + diff --git a/codegen/marketing/forms/models/HubSpotFormDefinition.ts b/codegen/marketing/forms/models/HubSpotFormDefinition.ts new file mode 100644 index 000000000..4278445c8 --- /dev/null +++ b/codegen/marketing/forms/models/HubSpotFormDefinition.ts @@ -0,0 +1,111 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { FieldGroup } from '../models/FieldGroup'; +import { FormDisplayOptions } from '../models/FormDisplayOptions'; +import { HubSpotFormConfiguration } from '../models/HubSpotFormConfiguration'; +import { HttpFile } from '../http/http'; + +export class HubSpotFormDefinition { + 'formType': HubSpotFormDefinitionFormTypeEnum; + 'id': string; + 'name': string; + 'createdAt': Date; + 'updatedAt': Date; + 'archived': boolean; + 'archivedAt'?: Date; + 'fieldGroups': Array; + 'configuration': HubSpotFormConfiguration; + 'displayOptions': FormDisplayOptions; + 'legalConsentOptions': any; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "formType", + "baseName": "formType", + "type": "HubSpotFormDefinitionFormTypeEnum", + "format": "" + }, + { + "name": "id", + "baseName": "id", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "createdAt", + "baseName": "createdAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "updatedAt", + "baseName": "updatedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "archived", + "baseName": "archived", + "type": "boolean", + "format": "" + }, + { + "name": "archivedAt", + "baseName": "archivedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "fieldGroups", + "baseName": "fieldGroups", + "type": "Array", + "format": "" + }, + { + "name": "configuration", + "baseName": "configuration", + "type": "HubSpotFormConfiguration", + "format": "" + }, + { + "name": "displayOptions", + "baseName": "displayOptions", + "type": "FormDisplayOptions", + "format": "" + }, + { + "name": "legalConsentOptions", + "baseName": "legalConsentOptions", + "type": "any", + "format": "" + } ]; + + static getAttributeTypeMap() { + return HubSpotFormDefinition.attributeTypeMap; + } + + public constructor() { + } +} + + +export type HubSpotFormDefinitionFormTypeEnum = "hubspot" ; + diff --git a/codegen/marketing/forms/models/HubSpotFormDefinitionAllOf.ts b/codegen/marketing/forms/models/HubSpotFormDefinitionAllOf.ts new file mode 100644 index 000000000..d96c3b39d --- /dev/null +++ b/codegen/marketing/forms/models/HubSpotFormDefinitionAllOf.ts @@ -0,0 +1,111 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { FieldGroup } from '../models/FieldGroup'; +import { FormDisplayOptions } from '../models/FormDisplayOptions'; +import { HubSpotFormConfiguration } from '../models/HubSpotFormConfiguration'; +import { HttpFile } from '../http/http'; + +export class HubSpotFormDefinitionAllOf { + 'formType': HubSpotFormDefinitionAllOfFormTypeEnum; + 'id': string; + 'name': string; + 'createdAt': Date; + 'updatedAt': Date; + 'archived': boolean; + 'archivedAt'?: Date; + 'fieldGroups': Array; + 'configuration': HubSpotFormConfiguration; + 'displayOptions': FormDisplayOptions; + 'legalConsentOptions': any; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "formType", + "baseName": "formType", + "type": "HubSpotFormDefinitionAllOfFormTypeEnum", + "format": "" + }, + { + "name": "id", + "baseName": "id", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "createdAt", + "baseName": "createdAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "updatedAt", + "baseName": "updatedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "archived", + "baseName": "archived", + "type": "boolean", + "format": "" + }, + { + "name": "archivedAt", + "baseName": "archivedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "fieldGroups", + "baseName": "fieldGroups", + "type": "Array", + "format": "" + }, + { + "name": "configuration", + "baseName": "configuration", + "type": "HubSpotFormConfiguration", + "format": "" + }, + { + "name": "displayOptions", + "baseName": "displayOptions", + "type": "FormDisplayOptions", + "format": "" + }, + { + "name": "legalConsentOptions", + "baseName": "legalConsentOptions", + "type": "any", + "format": "" + } ]; + + static getAttributeTypeMap() { + return HubSpotFormDefinitionAllOf.attributeTypeMap; + } + + public constructor() { + } +} + + +export type HubSpotFormDefinitionAllOfFormTypeEnum = "hubspot" ; + diff --git a/codegen/marketing/forms/models/HubSpotFormDefinitionCreateRequest.ts b/codegen/marketing/forms/models/HubSpotFormDefinitionCreateRequest.ts new file mode 100644 index 000000000..d5899f380 --- /dev/null +++ b/codegen/marketing/forms/models/HubSpotFormDefinitionCreateRequest.ts @@ -0,0 +1,104 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { FieldGroup } from '../models/FieldGroup'; +import { FormDisplayOptions } from '../models/FormDisplayOptions'; +import { HubSpotFormConfiguration } from '../models/HubSpotFormConfiguration'; +import { HttpFile } from '../http/http'; + +export class HubSpotFormDefinitionCreateRequest { + 'formType': HubSpotFormDefinitionCreateRequestFormTypeEnum; + 'name': string; + 'createdAt': Date; + 'updatedAt': Date; + 'archived': boolean; + 'archivedAt'?: Date; + 'fieldGroups': Array; + 'configuration': HubSpotFormConfiguration; + 'displayOptions': FormDisplayOptions; + 'legalConsentOptions': any; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "formType", + "baseName": "formType", + "type": "HubSpotFormDefinitionCreateRequestFormTypeEnum", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "createdAt", + "baseName": "createdAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "updatedAt", + "baseName": "updatedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "archived", + "baseName": "archived", + "type": "boolean", + "format": "" + }, + { + "name": "archivedAt", + "baseName": "archivedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "fieldGroups", + "baseName": "fieldGroups", + "type": "Array", + "format": "" + }, + { + "name": "configuration", + "baseName": "configuration", + "type": "HubSpotFormConfiguration", + "format": "" + }, + { + "name": "displayOptions", + "baseName": "displayOptions", + "type": "FormDisplayOptions", + "format": "" + }, + { + "name": "legalConsentOptions", + "baseName": "legalConsentOptions", + "type": "any", + "format": "" + } ]; + + static getAttributeTypeMap() { + return HubSpotFormDefinitionCreateRequest.attributeTypeMap; + } + + public constructor() { + } +} + + +export type HubSpotFormDefinitionCreateRequestFormTypeEnum = "hubspot" ; + diff --git a/codegen/marketing/forms/models/HubSpotFormDefinitionCreateRequestAllOf.ts b/codegen/marketing/forms/models/HubSpotFormDefinitionCreateRequestAllOf.ts new file mode 100644 index 000000000..dbdd329b8 --- /dev/null +++ b/codegen/marketing/forms/models/HubSpotFormDefinitionCreateRequestAllOf.ts @@ -0,0 +1,104 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { FieldGroup } from '../models/FieldGroup'; +import { FormDisplayOptions } from '../models/FormDisplayOptions'; +import { HubSpotFormConfiguration } from '../models/HubSpotFormConfiguration'; +import { HttpFile } from '../http/http'; + +export class HubSpotFormDefinitionCreateRequestAllOf { + 'formType': HubSpotFormDefinitionCreateRequestAllOfFormTypeEnum; + 'name': string; + 'createdAt': Date; + 'updatedAt': Date; + 'archived': boolean; + 'archivedAt'?: Date; + 'fieldGroups': Array; + 'configuration': HubSpotFormConfiguration; + 'displayOptions': FormDisplayOptions; + 'legalConsentOptions': any; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "formType", + "baseName": "formType", + "type": "HubSpotFormDefinitionCreateRequestAllOfFormTypeEnum", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "createdAt", + "baseName": "createdAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "updatedAt", + "baseName": "updatedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "archived", + "baseName": "archived", + "type": "boolean", + "format": "" + }, + { + "name": "archivedAt", + "baseName": "archivedAt", + "type": "Date", + "format": "date-time" + }, + { + "name": "fieldGroups", + "baseName": "fieldGroups", + "type": "Array", + "format": "" + }, + { + "name": "configuration", + "baseName": "configuration", + "type": "HubSpotFormConfiguration", + "format": "" + }, + { + "name": "displayOptions", + "baseName": "displayOptions", + "type": "FormDisplayOptions", + "format": "" + }, + { + "name": "legalConsentOptions", + "baseName": "legalConsentOptions", + "type": "any", + "format": "" + } ]; + + static getAttributeTypeMap() { + return HubSpotFormDefinitionCreateRequestAllOf.attributeTypeMap; + } + + public constructor() { + } +} + + +export type HubSpotFormDefinitionCreateRequestAllOfFormTypeEnum = "hubspot" ; + diff --git a/codegen/marketing/forms/models/HubSpotFormDefinitionPatchRequest.ts b/codegen/marketing/forms/models/HubSpotFormDefinitionPatchRequest.ts new file mode 100644 index 000000000..3dd8b37cc --- /dev/null +++ b/codegen/marketing/forms/models/HubSpotFormDefinitionPatchRequest.ts @@ -0,0 +1,83 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { FieldGroup } from '../models/FieldGroup'; +import { FormDisplayOptions } from '../models/FormDisplayOptions'; +import { HubSpotFormConfiguration } from '../models/HubSpotFormConfiguration'; +import { HubSpotFormDefinitionPatchRequestLegalConsentOptions } from '../models/HubSpotFormDefinitionPatchRequestLegalConsentOptions'; +import { HttpFile } from '../http/http'; + +export class HubSpotFormDefinitionPatchRequest { + /** + * The fields in the form, grouped in rows. + */ + 'fieldGroups'?: Array; + /** + * Whether this form is archived. + */ + 'archived'?: boolean; + 'configuration'?: HubSpotFormConfiguration; + /** + * The name of the form. Expected to be unique for a hub. + */ + 'name'?: string; + 'legalConsentOptions'?: HubSpotFormDefinitionPatchRequestLegalConsentOptions; + 'displayOptions'?: FormDisplayOptions; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldGroups", + "baseName": "fieldGroups", + "type": "Array", + "format": "" + }, + { + "name": "archived", + "baseName": "archived", + "type": "boolean", + "format": "" + }, + { + "name": "configuration", + "baseName": "configuration", + "type": "HubSpotFormConfiguration", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "legalConsentOptions", + "baseName": "legalConsentOptions", + "type": "HubSpotFormDefinitionPatchRequestLegalConsentOptions", + "format": "" + }, + { + "name": "displayOptions", + "baseName": "displayOptions", + "type": "FormDisplayOptions", + "format": "" + } ]; + + static getAttributeTypeMap() { + return HubSpotFormDefinitionPatchRequest.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/codegen/marketing/forms/models/HubSpotFormDefinitionPatchRequestLegalConsentOptions.ts b/codegen/marketing/forms/models/HubSpotFormDefinitionPatchRequestLegalConsentOptions.ts new file mode 100644 index 000000000..3f48b2735 --- /dev/null +++ b/codegen/marketing/forms/models/HubSpotFormDefinitionPatchRequestLegalConsentOptions.ts @@ -0,0 +1,100 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { LegalConsentCheckbox } from '../models/LegalConsentCheckbox'; +import { LegalConsentOptionsExplicitConsentToProcess } from '../models/LegalConsentOptionsExplicitConsentToProcess'; +import { LegalConsentOptionsImplicitConsentToProcess } from '../models/LegalConsentOptionsImplicitConsentToProcess'; +import { LegalConsentOptionsLegitimateInterest } from '../models/LegalConsentOptionsLegitimateInterest'; +import { LegalConsentOptionsNone } from '../models/LegalConsentOptionsNone'; +import { HttpFile } from '../http/http'; + +export class HubSpotFormDefinitionPatchRequestLegalConsentOptions { + 'type': HubSpotFormDefinitionPatchRequestLegalConsentOptionsTypeEnum; + 'subscriptionTypeIds': Array; + 'lawfulBasis': HubSpotFormDefinitionPatchRequestLegalConsentOptionsLawfulBasisEnum; + 'privacyText': string; + 'communicationConsentText'?: string; + 'communicationsCheckboxes': Array; + 'consentToProcessText'?: string; + 'consentToProcessCheckboxLabel'?: string; + 'consentToProcessFooterText'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "type", + "baseName": "type", + "type": "HubSpotFormDefinitionPatchRequestLegalConsentOptionsTypeEnum", + "format": "" + }, + { + "name": "subscriptionTypeIds", + "baseName": "subscriptionTypeIds", + "type": "Array", + "format": "int64" + }, + { + "name": "lawfulBasis", + "baseName": "lawfulBasis", + "type": "HubSpotFormDefinitionPatchRequestLegalConsentOptionsLawfulBasisEnum", + "format": "" + }, + { + "name": "privacyText", + "baseName": "privacyText", + "type": "string", + "format": "" + }, + { + "name": "communicationConsentText", + "baseName": "communicationConsentText", + "type": "string", + "format": "" + }, + { + "name": "communicationsCheckboxes", + "baseName": "communicationsCheckboxes", + "type": "Array", + "format": "" + }, + { + "name": "consentToProcessText", + "baseName": "consentToProcessText", + "type": "string", + "format": "" + }, + { + "name": "consentToProcessCheckboxLabel", + "baseName": "consentToProcessCheckboxLabel", + "type": "string", + "format": "" + }, + { + "name": "consentToProcessFooterText", + "baseName": "consentToProcessFooterText", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return HubSpotFormDefinitionPatchRequestLegalConsentOptions.attributeTypeMap; + } + + public constructor() { + } +} + + +export type HubSpotFormDefinitionPatchRequestLegalConsentOptionsTypeEnum = "implicit_consent_to_process" ; +export type HubSpotFormDefinitionPatchRequestLegalConsentOptionsLawfulBasisEnum = "lead" | "client" | "other" ; + diff --git a/codegen/marketing/forms/models/LegalConsentCheckbox.ts b/codegen/marketing/forms/models/LegalConsentCheckbox.ts new file mode 100644 index 000000000..c078502b0 --- /dev/null +++ b/codegen/marketing/forms/models/LegalConsentCheckbox.ts @@ -0,0 +1,55 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class LegalConsentCheckbox { + /** + * Whether this checkbox is required when submitting the form. + */ + 'required': boolean; + 'subscriptionTypeId': number; + /** + * The main label for the form field. + */ + 'label': string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "subscriptionTypeId", + "baseName": "subscriptionTypeId", + "type": "number", + "format": "int32" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return LegalConsentCheckbox.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/codegen/marketing/forms/models/LegalConsentOptionsExplicitConsentToProcess.ts b/codegen/marketing/forms/models/LegalConsentOptionsExplicitConsentToProcess.ts new file mode 100644 index 000000000..dd9ababa0 --- /dev/null +++ b/codegen/marketing/forms/models/LegalConsentOptionsExplicitConsentToProcess.ts @@ -0,0 +1,81 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { LegalConsentCheckbox } from '../models/LegalConsentCheckbox'; +import { HttpFile } from '../http/http'; + +export class LegalConsentOptionsExplicitConsentToProcess { + 'type': LegalConsentOptionsExplicitConsentToProcessTypeEnum; + 'communicationConsentText'?: string; + 'communicationsCheckboxes': Array; + 'consentToProcessText'?: string; + 'consentToProcessCheckboxLabel'?: string; + 'consentToProcessFooterText'?: string; + 'privacyText': string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "type", + "baseName": "type", + "type": "LegalConsentOptionsExplicitConsentToProcessTypeEnum", + "format": "" + }, + { + "name": "communicationConsentText", + "baseName": "communicationConsentText", + "type": "string", + "format": "" + }, + { + "name": "communicationsCheckboxes", + "baseName": "communicationsCheckboxes", + "type": "Array", + "format": "" + }, + { + "name": "consentToProcessText", + "baseName": "consentToProcessText", + "type": "string", + "format": "" + }, + { + "name": "consentToProcessCheckboxLabel", + "baseName": "consentToProcessCheckboxLabel", + "type": "string", + "format": "" + }, + { + "name": "consentToProcessFooterText", + "baseName": "consentToProcessFooterText", + "type": "string", + "format": "" + }, + { + "name": "privacyText", + "baseName": "privacyText", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return LegalConsentOptionsExplicitConsentToProcess.attributeTypeMap; + } + + public constructor() { + } +} + + +export type LegalConsentOptionsExplicitConsentToProcessTypeEnum = "explicit_consent_to_process" ; + diff --git a/codegen/marketing/forms/models/LegalConsentOptionsImplicitConsentToProcess.ts b/codegen/marketing/forms/models/LegalConsentOptionsImplicitConsentToProcess.ts new file mode 100644 index 000000000..cefbc962b --- /dev/null +++ b/codegen/marketing/forms/models/LegalConsentOptionsImplicitConsentToProcess.ts @@ -0,0 +1,67 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { LegalConsentCheckbox } from '../models/LegalConsentCheckbox'; +import { HttpFile } from '../http/http'; + +export class LegalConsentOptionsImplicitConsentToProcess { + 'type': LegalConsentOptionsImplicitConsentToProcessTypeEnum; + 'communicationConsentText'?: string; + 'communicationsCheckboxes': Array; + 'privacyText': string; + 'consentToProcessText'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "type", + "baseName": "type", + "type": "LegalConsentOptionsImplicitConsentToProcessTypeEnum", + "format": "" + }, + { + "name": "communicationConsentText", + "baseName": "communicationConsentText", + "type": "string", + "format": "" + }, + { + "name": "communicationsCheckboxes", + "baseName": "communicationsCheckboxes", + "type": "Array", + "format": "" + }, + { + "name": "privacyText", + "baseName": "privacyText", + "type": "string", + "format": "" + }, + { + "name": "consentToProcessText", + "baseName": "consentToProcessText", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return LegalConsentOptionsImplicitConsentToProcess.attributeTypeMap; + } + + public constructor() { + } +} + + +export type LegalConsentOptionsImplicitConsentToProcessTypeEnum = "implicit_consent_to_process" ; + diff --git a/codegen/marketing/forms/models/LegalConsentOptionsLegitimateInterest.ts b/codegen/marketing/forms/models/LegalConsentOptionsLegitimateInterest.ts new file mode 100644 index 000000000..9a9254bf2 --- /dev/null +++ b/codegen/marketing/forms/models/LegalConsentOptionsLegitimateInterest.ts @@ -0,0 +1,60 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class LegalConsentOptionsLegitimateInterest { + 'type': LegalConsentOptionsLegitimateInterestTypeEnum; + 'subscriptionTypeIds': Array; + 'lawfulBasis': LegalConsentOptionsLegitimateInterestLawfulBasisEnum; + 'privacyText': string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "type", + "baseName": "type", + "type": "LegalConsentOptionsLegitimateInterestTypeEnum", + "format": "" + }, + { + "name": "subscriptionTypeIds", + "baseName": "subscriptionTypeIds", + "type": "Array", + "format": "int64" + }, + { + "name": "lawfulBasis", + "baseName": "lawfulBasis", + "type": "LegalConsentOptionsLegitimateInterestLawfulBasisEnum", + "format": "" + }, + { + "name": "privacyText", + "baseName": "privacyText", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return LegalConsentOptionsLegitimateInterest.attributeTypeMap; + } + + public constructor() { + } +} + + +export type LegalConsentOptionsLegitimateInterestTypeEnum = "legitimate_interest" ; +export type LegalConsentOptionsLegitimateInterestLawfulBasisEnum = "lead" | "client" | "other" ; + diff --git a/codegen/marketing/forms/models/LegalConsentOptionsNone.ts b/codegen/marketing/forms/models/LegalConsentOptionsNone.ts new file mode 100644 index 000000000..21f85623c --- /dev/null +++ b/codegen/marketing/forms/models/LegalConsentOptionsNone.ts @@ -0,0 +1,38 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class LegalConsentOptionsNone { + 'type': LegalConsentOptionsNoneTypeEnum; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "type", + "baseName": "type", + "type": "LegalConsentOptionsNoneTypeEnum", + "format": "" + } ]; + + static getAttributeTypeMap() { + return LegalConsentOptionsNone.attributeTypeMap; + } + + public constructor() { + } +} + + +export type LegalConsentOptionsNoneTypeEnum = "none" ; + diff --git a/codegen/marketing/forms/models/MobilePhoneField.ts b/codegen/marketing/forms/models/MobilePhoneField.ts new file mode 100644 index 000000000..b7d41479a --- /dev/null +++ b/codegen/marketing/forms/models/MobilePhoneField.ts @@ -0,0 +1,143 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { PhoneFieldValidation } from '../models/PhoneFieldValidation'; +import { HttpFile } from '../http/http'; + +/** +* A form field used for collecting a mobile phone number. +*/ +export class MobilePhoneField { + /** + * Determines how the field will be displayed and validated. + */ + 'fieldType': MobilePhoneFieldFieldTypeEnum; + /** + * A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1. + */ + 'objectTypeId': string; + /** + * The identifier of the field. In combination with the object type ID, it must be unique. + */ + 'name': string; + /** + * The main label for the form field. + */ + 'label': string; + /** + * Additional text helping the customer to complete the field. + */ + 'description'?: string; + /** + * Whether a value for this field is required when submitting the form. + */ + 'required': boolean; + /** + * Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in. + */ + 'hidden': boolean; + /** + * A list of other fields to make visible based on the value filled in for this field. + */ + 'dependentFields': Array; + /** + * The prompt text showing when the field isn't filled in. + */ + 'placeholder'?: string; + /** + * The value filled in by default. This value will be submitted unless the customer modifies it. + */ + 'defaultValue'?: string; + 'validation': PhoneFieldValidation; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "MobilePhoneFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "placeholder", + "baseName": "placeholder", + "type": "string", + "format": "" + }, + { + "name": "defaultValue", + "baseName": "defaultValue", + "type": "string", + "format": "" + }, + { + "name": "validation", + "baseName": "validation", + "type": "PhoneFieldValidation", + "format": "" + } ]; + + static getAttributeTypeMap() { + return MobilePhoneField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type MobilePhoneFieldFieldTypeEnum = "mobile_phone" ; + diff --git a/codegen/marketing/forms/models/ModelError.ts b/codegen/marketing/forms/models/ModelError.ts new file mode 100644 index 000000000..5ce5e9b2f --- /dev/null +++ b/codegen/marketing/forms/models/ModelError.ts @@ -0,0 +1,99 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { ErrorDetail } from '../models/ErrorDetail'; +import { HttpFile } from '../http/http'; + +export class ModelError { + /** + * A specific category that contains more specific detail about the error + */ + 'subCategory'?: string; + /** + * Context about the error condition + */ + 'context'?: { [key: string]: Array; }; + /** + * A unique identifier for the request. Include this value with any error reports or support tickets + */ + 'correlationId': string; + /** + * A map of link names to associated URIs containing documentation about the error or recommended remediation steps + */ + 'links'?: { [key: string]: string; }; + /** + * A human readable message describing the error along with remediation steps where appropriate + */ + 'message': string; + /** + * The error category + */ + 'category': string; + /** + * further information about the error + */ + 'errors'?: Array; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "subCategory", + "baseName": "subCategory", + "type": "string", + "format": "" + }, + { + "name": "context", + "baseName": "context", + "type": "{ [key: string]: Array; }", + "format": "" + }, + { + "name": "correlationId", + "baseName": "correlationId", + "type": "string", + "format": "uuid" + }, + { + "name": "links", + "baseName": "links", + "type": "{ [key: string]: string; }", + "format": "" + }, + { + "name": "message", + "baseName": "message", + "type": "string", + "format": "" + }, + { + "name": "category", + "baseName": "category", + "type": "string", + "format": "" + }, + { + "name": "errors", + "baseName": "errors", + "type": "Array", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ModelError.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/codegen/marketing/forms/models/MultiLineTextField.ts b/codegen/marketing/forms/models/MultiLineTextField.ts new file mode 100644 index 000000000..e2b034716 --- /dev/null +++ b/codegen/marketing/forms/models/MultiLineTextField.ts @@ -0,0 +1,135 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { HttpFile } from '../http/http'; + +/** +* A form field consisting of a multiple-line text box. +*/ +export class MultiLineTextField { + /** + * Determines how the field will be displayed and validated. + */ + 'fieldType': MultiLineTextFieldFieldTypeEnum; + /** + * A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1. + */ + 'objectTypeId': string; + /** + * The identifier of the field. In combination with the object type ID, it must be unique. + */ + 'name': string; + /** + * The main label for the form field. + */ + 'label': string; + /** + * Additional text helping the customer to complete the field. + */ + 'description'?: string; + /** + * Whether a value for this field is required when submitting the form. + */ + 'required': boolean; + /** + * Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in. + */ + 'hidden': boolean; + /** + * A list of other fields to make visible based on the value filled in for this field. + */ + 'dependentFields': Array; + /** + * The prompt text showing when the field isn't filled in. + */ + 'placeholder'?: string; + /** + * The value filled in by default. This value will be submitted unless the customer modifies it. + */ + 'defaultValue'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "MultiLineTextFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "placeholder", + "baseName": "placeholder", + "type": "string", + "format": "" + }, + { + "name": "defaultValue", + "baseName": "defaultValue", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return MultiLineTextField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type MultiLineTextFieldFieldTypeEnum = "multi_line_text" ; + diff --git a/codegen/marketing/forms/models/MultipleCheckboxesField.ts b/codegen/marketing/forms/models/MultipleCheckboxesField.ts new file mode 100644 index 000000000..a017279de --- /dev/null +++ b/codegen/marketing/forms/models/MultipleCheckboxesField.ts @@ -0,0 +1,136 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { EnumeratedFieldOption } from '../models/EnumeratedFieldOption'; +import { HttpFile } from '../http/http'; + +/** +* A form field consisting of a set of checkboxes allowing multiple choices to be selected at one time. +*/ +export class MultipleCheckboxesField { + /** + * Determines how the field will be displayed and validated. + */ + 'fieldType': MultipleCheckboxesFieldFieldTypeEnum; + /** + * A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1. + */ + 'objectTypeId': string; + /** + * The identifier of the field. In combination with the object type ID, it must be unique. + */ + 'name': string; + /** + * The main label for the form field. + */ + 'label': string; + /** + * Additional text helping the customer to complete the field. + */ + 'description'?: string; + /** + * Whether a value for this field is required when submitting the form. + */ + 'required': boolean; + /** + * Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in. + */ + 'hidden': boolean; + /** + * A list of other fields to make visible based on the value filled in for this field. + */ + 'dependentFields': Array; + /** + * The values selected by default. Those values will be submitted unless the customer modifies them. + */ + 'defaultValues': Array; + /** + * The list of available choices for this field. + */ + 'options': Array; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "MultipleCheckboxesFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "defaultValues", + "baseName": "defaultValues", + "type": "Array", + "format": "" + }, + { + "name": "options", + "baseName": "options", + "type": "Array", + "format": "" + } ]; + + static getAttributeTypeMap() { + return MultipleCheckboxesField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type MultipleCheckboxesFieldFieldTypeEnum = "multiple_checkboxes" ; + diff --git a/codegen/marketing/forms/models/NextPage.ts b/codegen/marketing/forms/models/NextPage.ts new file mode 100644 index 000000000..7f86551e2 --- /dev/null +++ b/codegen/marketing/forms/models/NextPage.ts @@ -0,0 +1,48 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +export class NextPage { + /** + * + */ + 'link'?: string; + /** + * + */ + 'after': string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "link", + "baseName": "link", + "type": "string", + "format": "" + }, + { + "name": "after", + "baseName": "after", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return NextPage.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/codegen/marketing/forms/models/NumberField.ts b/codegen/marketing/forms/models/NumberField.ts new file mode 100644 index 000000000..a3e11f109 --- /dev/null +++ b/codegen/marketing/forms/models/NumberField.ts @@ -0,0 +1,143 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { NumberFieldValidation } from '../models/NumberFieldValidation'; +import { HttpFile } from '../http/http'; + +/** +* A form field used for collecting a numeric value. +*/ +export class NumberField { + /** + * Determines how the field will be displayed and validated. + */ + 'fieldType': NumberFieldFieldTypeEnum; + /** + * A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1. + */ + 'objectTypeId': string; + /** + * The identifier of the field. In combination with the object type ID, it must be unique. + */ + 'name': string; + /** + * The main label for the form field. + */ + 'label': string; + /** + * Additional text helping the customer to complete the field. + */ + 'description'?: string; + /** + * Whether a value for this field is required when submitting the form. + */ + 'required': boolean; + /** + * Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in. + */ + 'hidden': boolean; + /** + * A list of other fields to make visible based on the value filled in for this field. + */ + 'dependentFields': Array; + /** + * The prompt text showing when the field isn't filled in. + */ + 'placeholder'?: string; + /** + * The value filled in by default. This value will be submitted unless the customer modifies it. + */ + 'defaultValue'?: string; + 'validation'?: NumberFieldValidation; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "NumberFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "placeholder", + "baseName": "placeholder", + "type": "string", + "format": "" + }, + { + "name": "defaultValue", + "baseName": "defaultValue", + "type": "string", + "format": "" + }, + { + "name": "validation", + "baseName": "validation", + "type": "NumberFieldValidation", + "format": "" + } ]; + + static getAttributeTypeMap() { + return NumberField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type NumberFieldFieldTypeEnum = "number" ; + diff --git a/codegen/marketing/forms/models/NumberFieldValidation.ts b/codegen/marketing/forms/models/NumberFieldValidation.ts new file mode 100644 index 000000000..201e74861 --- /dev/null +++ b/codegen/marketing/forms/models/NumberFieldValidation.ts @@ -0,0 +1,45 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* Describes how a numeric value should be validated. +*/ +export class NumberFieldValidation { + 'minAllowedDigits': number; + 'maxAllowedDigits': number; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "minAllowedDigits", + "baseName": "minAllowedDigits", + "type": "number", + "format": "int32" + }, + { + "name": "maxAllowedDigits", + "baseName": "maxAllowedDigits", + "type": "number", + "format": "int32" + } ]; + + static getAttributeTypeMap() { + return NumberFieldValidation.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/codegen/marketing/forms/models/ObjectSerializer.ts b/codegen/marketing/forms/models/ObjectSerializer.ts new file mode 100644 index 000000000..8dfa4f0ff --- /dev/null +++ b/codegen/marketing/forms/models/ObjectSerializer.ts @@ -0,0 +1,393 @@ +export * from '../models/CollectionResponseFormDefinitionBaseForwardPaging'; +export * from '../models/CollectionResponseFormDefinitionBaseForwardPagingResultsInner'; +export * from '../models/DatepickerField'; +export * from '../models/DependentField'; +export * from '../models/DependentFieldDependentField'; +export * from '../models/DependentFieldFilter'; +export * from '../models/DropdownField'; +export * from '../models/EmailField'; +export * from '../models/EmailFieldValidation'; +export * from '../models/EnumeratedFieldOption'; +export * from '../models/ErrorDetail'; +export * from '../models/FieldGroup'; +export * from '../models/FileField'; +export * from '../models/FormDefinitionBase'; +export * from '../models/FormDefinitionCreateRequestBase'; +export * from '../models/FormDisplayOptions'; +export * from '../models/FormPostSubmitAction'; +export * from '../models/FormStyle'; +export * from '../models/ForwardPaging'; +export * from '../models/HubSpotFormConfiguration'; +export * from '../models/HubSpotFormDefinition'; +export * from '../models/HubSpotFormDefinitionAllOf'; +export * from '../models/HubSpotFormDefinitionCreateRequest'; +export * from '../models/HubSpotFormDefinitionCreateRequestAllOf'; +export * from '../models/HubSpotFormDefinitionPatchRequest'; +export * from '../models/HubSpotFormDefinitionPatchRequestLegalConsentOptions'; +export * from '../models/LegalConsentCheckbox'; +export * from '../models/LegalConsentOptionsExplicitConsentToProcess'; +export * from '../models/LegalConsentOptionsImplicitConsentToProcess'; +export * from '../models/LegalConsentOptionsLegitimateInterest'; +export * from '../models/LegalConsentOptionsNone'; +export * from '../models/MobilePhoneField'; +export * from '../models/ModelError'; +export * from '../models/MultiLineTextField'; +export * from '../models/MultipleCheckboxesField'; +export * from '../models/NextPage'; +export * from '../models/NumberField'; +export * from '../models/NumberFieldValidation'; +export * from '../models/PaymentLinkRadioField'; +export * from '../models/PhoneField'; +export * from '../models/PhoneFieldValidation'; +export * from '../models/RadioField'; +export * from '../models/SingleCheckboxField'; +export * from '../models/SingleLineTextField'; + +import { CollectionResponseFormDefinitionBaseForwardPaging } from '../models/CollectionResponseFormDefinitionBaseForwardPaging'; +import { CollectionResponseFormDefinitionBaseForwardPagingResultsInner, CollectionResponseFormDefinitionBaseForwardPagingResultsInnerFormTypeEnum } from '../models/CollectionResponseFormDefinitionBaseForwardPagingResultsInner'; +import { DatepickerField, DatepickerFieldFieldTypeEnum } from '../models/DatepickerField'; +import { DependentField } from '../models/DependentField'; +import { DependentFieldDependentField, DependentFieldDependentFieldFieldTypeEnum } from '../models/DependentFieldDependentField'; +import { DependentFieldFilter, DependentFieldFilterOperatorEnum } from '../models/DependentFieldFilter'; +import { DropdownField, DropdownFieldFieldTypeEnum } from '../models/DropdownField'; +import { EmailField, EmailFieldFieldTypeEnum } from '../models/EmailField'; +import { EmailFieldValidation } from '../models/EmailFieldValidation'; +import { EnumeratedFieldOption } from '../models/EnumeratedFieldOption'; +import { ErrorDetail } from '../models/ErrorDetail'; +import { FieldGroup, FieldGroupGroupTypeEnum , FieldGroupRichTextTypeEnum } from '../models/FieldGroup'; +import { FileField, FileFieldFieldTypeEnum } from '../models/FileField'; +import { FormDefinitionBase, FormDefinitionBaseFormTypeEnum } from '../models/FormDefinitionBase'; +import { FormDefinitionCreateRequestBase, FormDefinitionCreateRequestBaseFormTypeEnum } from '../models/FormDefinitionCreateRequestBase'; +import { FormDisplayOptions , FormDisplayOptionsThemeEnum } from '../models/FormDisplayOptions'; +import { FormPostSubmitAction, FormPostSubmitActionTypeEnum } from '../models/FormPostSubmitAction'; +import { FormStyle , FormStyleSubmitAlignmentEnum } from '../models/FormStyle'; +import { ForwardPaging } from '../models/ForwardPaging'; +import { HubSpotFormConfiguration , HubSpotFormConfigurationLanguageEnum } from '../models/HubSpotFormConfiguration'; +import { HubSpotFormDefinition, HubSpotFormDefinitionFormTypeEnum } from '../models/HubSpotFormDefinition'; +import { HubSpotFormDefinitionAllOf, HubSpotFormDefinitionAllOfFormTypeEnum } from '../models/HubSpotFormDefinitionAllOf'; +import { HubSpotFormDefinitionCreateRequest, HubSpotFormDefinitionCreateRequestFormTypeEnum } from '../models/HubSpotFormDefinitionCreateRequest'; +import { HubSpotFormDefinitionCreateRequestAllOf, HubSpotFormDefinitionCreateRequestAllOfFormTypeEnum } from '../models/HubSpotFormDefinitionCreateRequestAllOf'; +import { HubSpotFormDefinitionPatchRequest } from '../models/HubSpotFormDefinitionPatchRequest'; +import { HubSpotFormDefinitionPatchRequestLegalConsentOptions, HubSpotFormDefinitionPatchRequestLegalConsentOptionsTypeEnum , HubSpotFormDefinitionPatchRequestLegalConsentOptionsLawfulBasisEnum } from '../models/HubSpotFormDefinitionPatchRequestLegalConsentOptions'; +import { LegalConsentCheckbox } from '../models/LegalConsentCheckbox'; +import { LegalConsentOptionsExplicitConsentToProcess, LegalConsentOptionsExplicitConsentToProcessTypeEnum } from '../models/LegalConsentOptionsExplicitConsentToProcess'; +import { LegalConsentOptionsImplicitConsentToProcess, LegalConsentOptionsImplicitConsentToProcessTypeEnum } from '../models/LegalConsentOptionsImplicitConsentToProcess'; +import { LegalConsentOptionsLegitimateInterest, LegalConsentOptionsLegitimateInterestTypeEnum , LegalConsentOptionsLegitimateInterestLawfulBasisEnum } from '../models/LegalConsentOptionsLegitimateInterest'; +import { LegalConsentOptionsNone, LegalConsentOptionsNoneTypeEnum } from '../models/LegalConsentOptionsNone'; +import { MobilePhoneField, MobilePhoneFieldFieldTypeEnum } from '../models/MobilePhoneField'; +import { ModelError } from '../models/ModelError'; +import { MultiLineTextField, MultiLineTextFieldFieldTypeEnum } from '../models/MultiLineTextField'; +import { MultipleCheckboxesField, MultipleCheckboxesFieldFieldTypeEnum } from '../models/MultipleCheckboxesField'; +import { NextPage } from '../models/NextPage'; +import { NumberField, NumberFieldFieldTypeEnum } from '../models/NumberField'; +import { NumberFieldValidation } from '../models/NumberFieldValidation'; +import { PaymentLinkRadioField, PaymentLinkRadioFieldFieldTypeEnum } from '../models/PaymentLinkRadioField'; +import { PhoneField, PhoneFieldFieldTypeEnum } from '../models/PhoneField'; +import { PhoneFieldValidation } from '../models/PhoneFieldValidation'; +import { RadioField, RadioFieldFieldTypeEnum } from '../models/RadioField'; +import { SingleCheckboxField, SingleCheckboxFieldFieldTypeEnum } from '../models/SingleCheckboxField'; +import { SingleLineTextField, SingleLineTextFieldFieldTypeEnum } from '../models/SingleLineTextField'; + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +const supportedMediaTypes: { [mediaType: string]: number } = { + "application/json": Infinity, + "application/octet-stream": 0, + "application/x-www-form-urlencoded": 0 +} + + +let enumsMap: Set = new Set([ + "CollectionResponseFormDefinitionBaseForwardPagingResultsInnerFormTypeEnum", + "DatepickerFieldFieldTypeEnum", + "DependentFieldDependentFieldFieldTypeEnum", + "DependentFieldFilterOperatorEnum", + "DropdownFieldFieldTypeEnum", + "EmailFieldFieldTypeEnum", + "FieldGroupGroupTypeEnum", + "FieldGroupRichTextTypeEnum", + "FileFieldFieldTypeEnum", + "FormDefinitionBaseFormTypeEnum", + "FormDefinitionCreateRequestBaseFormTypeEnum", + "FormDisplayOptionsThemeEnum", + "FormPostSubmitActionTypeEnum", + "FormStyleSubmitAlignmentEnum", + "HubSpotFormConfigurationLanguageEnum", + "HubSpotFormDefinitionFormTypeEnum", + "HubSpotFormDefinitionAllOfFormTypeEnum", + "HubSpotFormDefinitionCreateRequestFormTypeEnum", + "HubSpotFormDefinitionCreateRequestAllOfFormTypeEnum", + "HubSpotFormDefinitionPatchRequestLegalConsentOptionsTypeEnum", + "HubSpotFormDefinitionPatchRequestLegalConsentOptionsLawfulBasisEnum", + "LegalConsentOptionsExplicitConsentToProcessTypeEnum", + "LegalConsentOptionsImplicitConsentToProcessTypeEnum", + "LegalConsentOptionsLegitimateInterestTypeEnum", + "LegalConsentOptionsLegitimateInterestLawfulBasisEnum", + "LegalConsentOptionsNoneTypeEnum", + "MobilePhoneFieldFieldTypeEnum", + "MultiLineTextFieldFieldTypeEnum", + "MultipleCheckboxesFieldFieldTypeEnum", + "NumberFieldFieldTypeEnum", + "PaymentLinkRadioFieldFieldTypeEnum", + "PhoneFieldFieldTypeEnum", + "RadioFieldFieldTypeEnum", + "SingleCheckboxFieldFieldTypeEnum", + "SingleLineTextFieldFieldTypeEnum", +]); + +let typeMap: {[index: string]: any} = { + "CollectionResponseFormDefinitionBaseForwardPaging": CollectionResponseFormDefinitionBaseForwardPaging, + "CollectionResponseFormDefinitionBaseForwardPagingResultsInner": CollectionResponseFormDefinitionBaseForwardPagingResultsInner, + "DatepickerField": DatepickerField, + "DependentField": DependentField, + "DependentFieldDependentField": DependentFieldDependentField, + "DependentFieldFilter": DependentFieldFilter, + "DropdownField": DropdownField, + "EmailField": EmailField, + "EmailFieldValidation": EmailFieldValidation, + "EnumeratedFieldOption": EnumeratedFieldOption, + "ErrorDetail": ErrorDetail, + "FieldGroup": FieldGroup, + "FileField": FileField, + "FormDefinitionBase": FormDefinitionBase, + "FormDefinitionCreateRequestBase": FormDefinitionCreateRequestBase, + "FormDisplayOptions": FormDisplayOptions, + "FormPostSubmitAction": FormPostSubmitAction, + "FormStyle": FormStyle, + "ForwardPaging": ForwardPaging, + "HubSpotFormConfiguration": HubSpotFormConfiguration, + "HubSpotFormDefinition": HubSpotFormDefinition, + "HubSpotFormDefinitionAllOf": HubSpotFormDefinitionAllOf, + "HubSpotFormDefinitionCreateRequest": HubSpotFormDefinitionCreateRequest, + "HubSpotFormDefinitionCreateRequestAllOf": HubSpotFormDefinitionCreateRequestAllOf, + "HubSpotFormDefinitionPatchRequest": HubSpotFormDefinitionPatchRequest, + "HubSpotFormDefinitionPatchRequestLegalConsentOptions": HubSpotFormDefinitionPatchRequestLegalConsentOptions, + "LegalConsentCheckbox": LegalConsentCheckbox, + "LegalConsentOptionsExplicitConsentToProcess": LegalConsentOptionsExplicitConsentToProcess, + "LegalConsentOptionsImplicitConsentToProcess": LegalConsentOptionsImplicitConsentToProcess, + "LegalConsentOptionsLegitimateInterest": LegalConsentOptionsLegitimateInterest, + "LegalConsentOptionsNone": LegalConsentOptionsNone, + "MobilePhoneField": MobilePhoneField, + "ModelError": ModelError, + "MultiLineTextField": MultiLineTextField, + "MultipleCheckboxesField": MultipleCheckboxesField, + "NextPage": NextPage, + "NumberField": NumberField, + "NumberFieldValidation": NumberFieldValidation, + "PaymentLinkRadioField": PaymentLinkRadioField, + "PhoneField": PhoneField, + "PhoneFieldValidation": PhoneFieldValidation, + "RadioField": RadioField, + "SingleCheckboxField": SingleCheckboxField, + "SingleLineTextField": SingleLineTextField, +} + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + 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; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if(typeMap[discriminatorType]){ + return discriminatorType; // use the type given in the discriminator + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string, format: string) { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let date of data) { + transformedData.push(ObjectSerializer.serialize(date, 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]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let attributeType of attributeTypes) { + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format); + } + return instance; + } + } + + public static deserialize(data: any, type: string, format: string) { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let date of data) { + transformedData.push(ObjectSerializer.deserialize(date, subType, format)); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap.has(type)) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the 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; + } + } + + + /** + * Normalize media type + * + * We currently do not handle any media types attributes, i.e. anything + * after a semicolon. All content is assumed to be UTF-8 compatible. + */ + public static normalizeMediaType(mediaType: string | undefined): string | undefined { + if (mediaType === undefined) { + return undefined; + } + return mediaType.split(";")[0].trim().toLowerCase(); + } + + /** + * From a list of possible media types, choose the one we can handle best. + * + * The order of the given media types does not have any impact on the choice + * made. + */ + public static getPreferredMediaType(mediaTypes: Array): string { + /** According to OAS 3 we should default to json */ + if (!mediaTypes) { + return "application/json"; + } + + const normalMediaTypes = mediaTypes.map(this.normalizeMediaType); + let selectedMediaType: string | undefined = undefined; + let selectedRank: number = -Infinity; + for (const mediaType of normalMediaTypes) { + if (supportedMediaTypes[mediaType!] > selectedRank) { + selectedMediaType = mediaType; + selectedRank = supportedMediaTypes[mediaType!]; + } + } + + if (selectedMediaType === undefined) { + throw new Error("None of the given media types are supported: " + mediaTypes.join(", ")); + } + + return selectedMediaType!; + } + + /** + * Convert data to a string according the given media type + */ + public static stringify(data: any, mediaType: string): string { + if (mediaType === "text/plain") { + return String(data); + } + + if (mediaType === "application/json") { + return JSON.stringify(data); + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify."); + } + + /** + * Parse data from a string according to the given media type + */ + public static parse(rawData: string, mediaType: string | undefined) { + if (mediaType === undefined) { + throw new Error("Cannot parse content. No Content-Type defined."); + } + + if (mediaType === "text/plain") { + return rawData; + } + + if (mediaType === "application/json") { + return JSON.parse(rawData); + } + + if (mediaType === "text/html") { + return rawData; + } + + throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse."); + } +} diff --git a/codegen/marketing/forms/models/PaymentLinkRadioField.ts b/codegen/marketing/forms/models/PaymentLinkRadioField.ts new file mode 100644 index 000000000..a7e000df2 --- /dev/null +++ b/codegen/marketing/forms/models/PaymentLinkRadioField.ts @@ -0,0 +1,103 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { EnumeratedFieldOption } from '../models/EnumeratedFieldOption'; +import { HttpFile } from '../http/http'; + +export class PaymentLinkRadioField { + 'fieldType': PaymentLinkRadioFieldFieldTypeEnum; + 'objectTypeId': string; + 'name': string; + 'label': string; + 'description'?: string; + 'required': boolean; + 'hidden': boolean; + 'dependentFields': Array; + 'defaultValues': Array; + 'options': Array; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "PaymentLinkRadioFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "defaultValues", + "baseName": "defaultValues", + "type": "Array", + "format": "" + }, + { + "name": "options", + "baseName": "options", + "type": "Array", + "format": "" + } ]; + + static getAttributeTypeMap() { + return PaymentLinkRadioField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type PaymentLinkRadioFieldFieldTypeEnum = "payment_link_radio" ; + diff --git a/codegen/marketing/forms/models/PhoneField.ts b/codegen/marketing/forms/models/PhoneField.ts new file mode 100644 index 000000000..8daeebefc --- /dev/null +++ b/codegen/marketing/forms/models/PhoneField.ts @@ -0,0 +1,153 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { PhoneFieldValidation } from '../models/PhoneFieldValidation'; +import { HttpFile } from '../http/http'; + +/** +* A form field used for collecting a phone number. +*/ +export class PhoneField { + /** + * Determines how the field will be displayed and validated. + */ + 'fieldType': PhoneFieldFieldTypeEnum; + /** + * A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1. + */ + 'objectTypeId': string; + /** + * The identifier of the field. In combination with the object type ID, it must be unique. + */ + 'name': string; + /** + * The main label for the form field. + */ + 'label': string; + /** + * Additional text helping the customer to complete the field. + */ + 'description'?: string; + /** + * Whether a value for this field is required when submitting the form. + */ + 'required': boolean; + /** + * Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in. + */ + 'hidden': boolean; + /** + * A list of other fields to make visible based on the value filled in for this field. + */ + 'dependentFields': Array; + /** + * The prompt text showing when the field isn't filled in. + */ + 'placeholder'?: string; + /** + * The value filled in by default. This value will be submitted unless the customer modifies it. + */ + 'defaultValue'?: string; + /** + * Whether to display a country code drop down next to the phone field. + */ + 'useCountryCodeSelect': boolean; + 'validation': PhoneFieldValidation; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "PhoneFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "placeholder", + "baseName": "placeholder", + "type": "string", + "format": "" + }, + { + "name": "defaultValue", + "baseName": "defaultValue", + "type": "string", + "format": "" + }, + { + "name": "useCountryCodeSelect", + "baseName": "useCountryCodeSelect", + "type": "boolean", + "format": "" + }, + { + "name": "validation", + "baseName": "validation", + "type": "PhoneFieldValidation", + "format": "" + } ]; + + static getAttributeTypeMap() { + return PhoneField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type PhoneFieldFieldTypeEnum = "phone" ; + diff --git a/codegen/marketing/forms/models/PhoneFieldValidation.ts b/codegen/marketing/forms/models/PhoneFieldValidation.ts new file mode 100644 index 000000000..59ad8d339 --- /dev/null +++ b/codegen/marketing/forms/models/PhoneFieldValidation.ts @@ -0,0 +1,45 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { HttpFile } from '../http/http'; + +/** +* Describes how a phone number should be validated. +*/ +export class PhoneFieldValidation { + 'minAllowedDigits': number; + 'maxAllowedDigits': number; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "minAllowedDigits", + "baseName": "minAllowedDigits", + "type": "number", + "format": "int32" + }, + { + "name": "maxAllowedDigits", + "baseName": "maxAllowedDigits", + "type": "number", + "format": "int32" + } ]; + + static getAttributeTypeMap() { + return PhoneFieldValidation.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/codegen/marketing/forms/models/RadioField.ts b/codegen/marketing/forms/models/RadioField.ts new file mode 100644 index 000000000..a2d48bb42 --- /dev/null +++ b/codegen/marketing/forms/models/RadioField.ts @@ -0,0 +1,146 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { EnumeratedFieldOption } from '../models/EnumeratedFieldOption'; +import { HttpFile } from '../http/http'; + +/** +* A form field consisting of a set of radio options, out of which one can be selected at a time. +*/ +export class RadioField { + /** + * Determines how the field will be displayed and validated. + */ + 'fieldType': RadioFieldFieldTypeEnum; + /** + * A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1. + */ + 'objectTypeId': string; + /** + * The identifier of the field. In combination with the object type ID, it must be unique. + */ + 'name': string; + /** + * The main label for the form field. + */ + 'label': string; + /** + * Additional text helping the customer to complete the field. + */ + 'description'?: string; + /** + * Whether a value for this field is required when submitting the form. + */ + 'required': boolean; + /** + * Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in. + */ + 'hidden': boolean; + /** + * A list of other fields to make visible based on the value filled in for this field. + */ + 'dependentFields': Array; + /** + * The values selected by default. Those values will be submitted unless the customer modifies them. + */ + 'defaultValues': Array; + /** + * The list of available choices for this field. + */ + 'options': Array; + /** + * The prompt text showing when the field isn't filled in. + */ + 'placeholder'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "RadioFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "defaultValues", + "baseName": "defaultValues", + "type": "Array", + "format": "" + }, + { + "name": "options", + "baseName": "options", + "type": "Array", + "format": "" + }, + { + "name": "placeholder", + "baseName": "placeholder", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return RadioField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type RadioFieldFieldTypeEnum = "radio" ; + diff --git a/codegen/marketing/forms/models/SingleCheckboxField.ts b/codegen/marketing/forms/models/SingleCheckboxField.ts new file mode 100644 index 000000000..735c66114 --- /dev/null +++ b/codegen/marketing/forms/models/SingleCheckboxField.ts @@ -0,0 +1,125 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { HttpFile } from '../http/http'; + +/** +* A form field consisting of a single checkbox. +*/ +export class SingleCheckboxField { + /** + * Determines how the field will be displayed and validated. + */ + 'fieldType': SingleCheckboxFieldFieldTypeEnum; + /** + * A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1. + */ + 'objectTypeId': string; + /** + * The identifier of the field. In combination with the object type ID, it must be unique. + */ + 'name': string; + /** + * The main label for the form field. + */ + 'label': string; + /** + * Additional text helping the customer to complete the field. + */ + 'description'?: string; + /** + * Whether a value for this field is required when submitting the form. + */ + 'required': boolean; + /** + * Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in. + */ + 'hidden': boolean; + /** + * A list of other fields to make visible based on the value filled in for this field. + */ + 'dependentFields': Array; + /** + * The value filled in by default. This value will be submitted unless the customer modifies it. + */ + 'defaultValue'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "SingleCheckboxFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "defaultValue", + "baseName": "defaultValue", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return SingleCheckboxField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type SingleCheckboxFieldFieldTypeEnum = "single_checkbox" ; + diff --git a/codegen/marketing/forms/models/SingleLineTextField.ts b/codegen/marketing/forms/models/SingleLineTextField.ts new file mode 100644 index 000000000..4a151d103 --- /dev/null +++ b/codegen/marketing/forms/models/SingleLineTextField.ts @@ -0,0 +1,135 @@ +/** + * Forms + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: v3 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { DependentField } from '../models/DependentField'; +import { HttpFile } from '../http/http'; + +/** +* A form field consisting of a single-line text box. +*/ +export class SingleLineTextField { + /** + * Determines how the field will be displayed and validated. + */ + 'fieldType': SingleLineTextFieldFieldTypeEnum; + /** + * A unique ID for this field's CRM object type. For example a CONTACT field will have the object type ID 0-1. + */ + 'objectTypeId': string; + /** + * The identifier of the field. In combination with the object type ID, it must be unique. + */ + 'name': string; + /** + * The main label for the form field. + */ + 'label': string; + /** + * Additional text helping the customer to complete the field. + */ + 'description'?: string; + /** + * Whether a value for this field is required when submitting the form. + */ + 'required': boolean; + /** + * Whether a field should be hidden or not. Hidden fields won't appear on the form, but can be used to pass a value to a property without requiring the customer to fill it in. + */ + 'hidden': boolean; + /** + * A list of other fields to make visible based on the value filled in for this field. + */ + 'dependentFields': Array; + /** + * The prompt text showing when the field isn't filled in. + */ + 'placeholder'?: string; + /** + * The value filled in by default. This value will be submitted unless the customer modifies it. + */ + 'defaultValue'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "fieldType", + "baseName": "fieldType", + "type": "SingleLineTextFieldFieldTypeEnum", + "format": "" + }, + { + "name": "objectTypeId", + "baseName": "objectTypeId", + "type": "string", + "format": "" + }, + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "label", + "baseName": "label", + "type": "string", + "format": "" + }, + { + "name": "description", + "baseName": "description", + "type": "string", + "format": "" + }, + { + "name": "required", + "baseName": "required", + "type": "boolean", + "format": "" + }, + { + "name": "hidden", + "baseName": "hidden", + "type": "boolean", + "format": "" + }, + { + "name": "dependentFields", + "baseName": "dependentFields", + "type": "Array", + "format": "" + }, + { + "name": "placeholder", + "baseName": "placeholder", + "type": "string", + "format": "" + }, + { + "name": "defaultValue", + "baseName": "defaultValue", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return SingleLineTextField.attributeTypeMap; + } + + public constructor() { + } +} + + +export type SingleLineTextFieldFieldTypeEnum = "single_line_text" ; + diff --git a/codegen/marketing/forms/models/all.ts b/codegen/marketing/forms/models/all.ts new file mode 100644 index 000000000..9914e32ef --- /dev/null +++ b/codegen/marketing/forms/models/all.ts @@ -0,0 +1,44 @@ +export * from '../models/CollectionResponseFormDefinitionBaseForwardPaging' +export * from '../models/CollectionResponseFormDefinitionBaseForwardPagingResultsInner' +export * from '../models/DatepickerField' +export * from '../models/DependentField' +export * from '../models/DependentFieldDependentField' +export * from '../models/DependentFieldFilter' +export * from '../models/DropdownField' +export * from '../models/EmailField' +export * from '../models/EmailFieldValidation' +export * from '../models/EnumeratedFieldOption' +export * from '../models/ErrorDetail' +export * from '../models/FieldGroup' +export * from '../models/FileField' +export * from '../models/FormDefinitionBase' +export * from '../models/FormDefinitionCreateRequestBase' +export * from '../models/FormDisplayOptions' +export * from '../models/FormPostSubmitAction' +export * from '../models/FormStyle' +export * from '../models/ForwardPaging' +export * from '../models/HubSpotFormConfiguration' +export * from '../models/HubSpotFormDefinition' +export * from '../models/HubSpotFormDefinitionAllOf' +export * from '../models/HubSpotFormDefinitionCreateRequest' +export * from '../models/HubSpotFormDefinitionCreateRequestAllOf' +export * from '../models/HubSpotFormDefinitionPatchRequest' +export * from '../models/HubSpotFormDefinitionPatchRequestLegalConsentOptions' +export * from '../models/LegalConsentCheckbox' +export * from '../models/LegalConsentOptionsExplicitConsentToProcess' +export * from '../models/LegalConsentOptionsImplicitConsentToProcess' +export * from '../models/LegalConsentOptionsLegitimateInterest' +export * from '../models/LegalConsentOptionsNone' +export * from '../models/MobilePhoneField' +export * from '../models/ModelError' +export * from '../models/MultiLineTextField' +export * from '../models/MultipleCheckboxesField' +export * from '../models/NextPage' +export * from '../models/NumberField' +export * from '../models/NumberFieldValidation' +export * from '../models/PaymentLinkRadioField' +export * from '../models/PhoneField' +export * from '../models/PhoneFieldValidation' +export * from '../models/RadioField' +export * from '../models/SingleCheckboxField' +export * from '../models/SingleLineTextField' diff --git a/codegen/marketing/forms/rxjsStub.ts b/codegen/marketing/forms/rxjsStub.ts new file mode 100644 index 000000000..4c73715a2 --- /dev/null +++ b/codegen/marketing/forms/rxjsStub.ts @@ -0,0 +1,27 @@ +export class Observable { + constructor(private promise: Promise) {} + + toPromise() { + return this.promise; + } + + pipe(callback: (value: T) => S | Promise): Observable { + return new Observable(this.promise.then(callback)); + } +} + +export function from(promise: Promise) { + return new Observable(promise); +} + +export function of(value: T) { + return new Observable(Promise.resolve(value)); +} + +export function mergeMap(callback: (value: T) => Observable) { + return (value: T) => callback(value).toPromise(); +} + +export function map(callback: any) { + return callback; +} diff --git a/codegen/marketing/forms/servers.ts b/codegen/marketing/forms/servers.ts new file mode 100644 index 000000000..022acd6fd --- /dev/null +++ b/codegen/marketing/forms/servers.ts @@ -0,0 +1,55 @@ +import { RequestContext, HttpMethod } from "./http/http"; + +export interface BaseServerConfiguration { + makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext; +} + +/** + * + * Represents the configuration of a server including its + * url template and variable configuration based on the url. + * + */ +export class ServerConfiguration implements BaseServerConfiguration { + public constructor(private url: string, private variableConfiguration: T) {} + + /** + * Sets the value of the variables of this server. Variables are included in + * the `url` of this ServerConfiguration in the form `{variableName}` + * + * @param variableConfiguration a partial variable configuration for the + * variables contained in the url + */ + public setVariables(variableConfiguration: Partial) { + Object.assign(this.variableConfiguration, variableConfiguration); + } + + public getConfiguration(): T { + return this.variableConfiguration + } + + private getUrl() { + let replacedUrl = this.url; + for (const key in this.variableConfiguration) { + var re = new RegExp("{" + key + "}","g"); + replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]); + } + return replacedUrl + } + + /** + * Creates a new request context for this server using the url with variables + * replaced with their respective values and the endpoint of the request appended. + * + * @param endpoint the endpoint to be queried on the server + * @param httpMethod httpMethod to be used + * + */ + public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext { + return new RequestContext(this.getUrl() + endpoint, httpMethod); + } +} + +export const server1 = new ServerConfiguration<{ }>("https://api.hubapi.com", { }) + +export const servers = [server1]; diff --git a/codegen/marketing/forms/types/ObjectParamAPI.ts b/codegen/marketing/forms/types/ObjectParamAPI.ts new file mode 100644 index 000000000..7a9daba8f --- /dev/null +++ b/codegen/marketing/forms/types/ObjectParamAPI.ts @@ -0,0 +1,203 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import { Configuration} from '../configuration' + +import { CollectionResponseFormDefinitionBaseForwardPaging } from '../models/CollectionResponseFormDefinitionBaseForwardPaging'; +import { CollectionResponseFormDefinitionBaseForwardPagingResultsInner } from '../models/CollectionResponseFormDefinitionBaseForwardPagingResultsInner'; +import { DatepickerField } from '../models/DatepickerField'; +import { DependentField } from '../models/DependentField'; +import { DependentFieldDependentField } from '../models/DependentFieldDependentField'; +import { DependentFieldFilter } from '../models/DependentFieldFilter'; +import { DropdownField } from '../models/DropdownField'; +import { EmailField } from '../models/EmailField'; +import { EmailFieldValidation } from '../models/EmailFieldValidation'; +import { EnumeratedFieldOption } from '../models/EnumeratedFieldOption'; +import { ErrorDetail } from '../models/ErrorDetail'; +import { FieldGroup } from '../models/FieldGroup'; +import { FileField } from '../models/FileField'; +import { FormDefinitionBase } from '../models/FormDefinitionBase'; +import { FormDefinitionCreateRequestBase } from '../models/FormDefinitionCreateRequestBase'; +import { FormDisplayOptions } from '../models/FormDisplayOptions'; +import { FormPostSubmitAction } from '../models/FormPostSubmitAction'; +import { FormStyle } from '../models/FormStyle'; +import { ForwardPaging } from '../models/ForwardPaging'; +import { HubSpotFormConfiguration } from '../models/HubSpotFormConfiguration'; +import { HubSpotFormDefinition } from '../models/HubSpotFormDefinition'; +import { HubSpotFormDefinitionAllOf } from '../models/HubSpotFormDefinitionAllOf'; +import { HubSpotFormDefinitionCreateRequest } from '../models/HubSpotFormDefinitionCreateRequest'; +import { HubSpotFormDefinitionCreateRequestAllOf } from '../models/HubSpotFormDefinitionCreateRequestAllOf'; +import { HubSpotFormDefinitionPatchRequest } from '../models/HubSpotFormDefinitionPatchRequest'; +import { HubSpotFormDefinitionPatchRequestLegalConsentOptions } from '../models/HubSpotFormDefinitionPatchRequestLegalConsentOptions'; +import { LegalConsentCheckbox } from '../models/LegalConsentCheckbox'; +import { LegalConsentOptionsExplicitConsentToProcess } from '../models/LegalConsentOptionsExplicitConsentToProcess'; +import { LegalConsentOptionsImplicitConsentToProcess } from '../models/LegalConsentOptionsImplicitConsentToProcess'; +import { LegalConsentOptionsLegitimateInterest } from '../models/LegalConsentOptionsLegitimateInterest'; +import { LegalConsentOptionsNone } from '../models/LegalConsentOptionsNone'; +import { MobilePhoneField } from '../models/MobilePhoneField'; +import { ModelError } from '../models/ModelError'; +import { MultiLineTextField } from '../models/MultiLineTextField'; +import { MultipleCheckboxesField } from '../models/MultipleCheckboxesField'; +import { NextPage } from '../models/NextPage'; +import { NumberField } from '../models/NumberField'; +import { NumberFieldValidation } from '../models/NumberFieldValidation'; +import { PaymentLinkRadioField } from '../models/PaymentLinkRadioField'; +import { PhoneField } from '../models/PhoneField'; +import { PhoneFieldValidation } from '../models/PhoneFieldValidation'; +import { RadioField } from '../models/RadioField'; +import { SingleCheckboxField } from '../models/SingleCheckboxField'; +import { SingleLineTextField } from '../models/SingleLineTextField'; + +import { ObservableFormsApi } from "./ObservableAPI"; +import { FormsApiRequestFactory, FormsApiResponseProcessor} from "../apis/FormsApi"; + +export interface FormsApiArchiveRequest { + /** + * The ID of the form to archive. + * @type string + * @memberof FormsApiarchive + */ + formId: string +} + +export interface FormsApiCreateRequest { + /** + * + * @type FormDefinitionCreateRequestBase + * @memberof FormsApicreate + */ + formDefinitionCreateRequestBase: FormDefinitionCreateRequestBase +} + +export interface FormsApiGetByIdRequest { + /** + * The unique identifier of the form + * @type string + * @memberof FormsApigetById + */ + formId: string + /** + * Whether to return only results that have been archived. + * @type boolean + * @memberof FormsApigetById + */ + archived?: boolean +} + +export interface FormsApiGetPageRequest { + /** + * The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. + * @type string + * @memberof FormsApigetPage + */ + after?: string + /** + * The maximum number of results to display per page. + * @type number + * @memberof FormsApigetPage + */ + limit?: number + /** + * Whether to return only results that have been archived. + * @type boolean + * @memberof FormsApigetPage + */ + archived?: boolean + /** + * The form types to be included in the results. + * @type Array<'hubspot' | 'captured' | 'flow' | 'blog_comment' | 'all'> + * @memberof FormsApigetPage + */ + formTypes?: Array<'hubspot' | 'captured' | 'flow' | 'blog_comment' | 'all'> +} + +export interface FormsApiReplaceRequest { + /** + * + * @type string + * @memberof FormsApireplace + */ + formId: string + /** + * + * @type HubSpotFormDefinition + * @memberof FormsApireplace + */ + hubSpotFormDefinition: HubSpotFormDefinition +} + +export interface FormsApiUpdateRequest { + /** + * The ID of the form to update. + * @type string + * @memberof FormsApiupdate + */ + formId: string + /** + * + * @type HubSpotFormDefinitionPatchRequest + * @memberof FormsApiupdate + */ + hubSpotFormDefinitionPatchRequest: HubSpotFormDefinitionPatchRequest +} + +export class ObjectFormsApi { + private api: ObservableFormsApi + + public constructor(configuration: Configuration, requestFactory?: FormsApiRequestFactory, responseProcessor?: FormsApiResponseProcessor) { + this.api = new ObservableFormsApi(configuration, requestFactory, responseProcessor); + } + + /** + * Archive a form definition. New submissions will not be accepted and the form definition will be permanently deleted after 3 months. + * Archive a form definition + * @param param the request object + */ + public archive(param: FormsApiArchiveRequest, options?: Configuration): Promise { + return this.api.archive(param.formId, options).toPromise(); + } + + /** + * Add a new `hubspot` form + * Create a form + * @param param the request object + */ + public create(param: FormsApiCreateRequest, options?: Configuration): Promise { + return this.api.create(param.formDefinitionCreateRequestBase, options).toPromise(); + } + + /** + * Returns a form based on the form ID provided. + * Get a form definition + * @param param the request object + */ + public getById(param: FormsApiGetByIdRequest, options?: Configuration): Promise { + return this.api.getById(param.formId, param.archived, options).toPromise(); + } + + /** + * Returns a list of forms based on the search filters. By default, it returns the first 20 `hubspot` forms + * Get a list of forms + * @param param the request object + */ + public getPage(param: FormsApiGetPageRequest = {}, options?: Configuration): Promise { + return this.api.getPage(param.after, param.limit, param.archived, param.formTypes, options).toPromise(); + } + + /** + * Update all fields of a hubspot form definition. + * Update a form definition + * @param param the request object + */ + public replace(param: FormsApiReplaceRequest, options?: Configuration): Promise { + return this.api.replace(param.formId, param.hubSpotFormDefinition, options).toPromise(); + } + + /** + * Update some of the form definition components + * Partially update a form definition + * @param param the request object + */ + public update(param: FormsApiUpdateRequest, options?: Configuration): Promise { + return this.api.update(param.formId, param.hubSpotFormDefinitionPatchRequest, options).toPromise(); + } + +} diff --git a/codegen/marketing/forms/types/ObservableAPI.ts b/codegen/marketing/forms/types/ObservableAPI.ts new file mode 100644 index 000000000..ec28d65a8 --- /dev/null +++ b/codegen/marketing/forms/types/ObservableAPI.ts @@ -0,0 +1,216 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import { Configuration} from '../configuration' +import { Observable, of, from } from '../rxjsStub'; +import {mergeMap, map} from '../rxjsStub'; +import { CollectionResponseFormDefinitionBaseForwardPaging } from '../models/CollectionResponseFormDefinitionBaseForwardPaging'; +import { CollectionResponseFormDefinitionBaseForwardPagingResultsInner } from '../models/CollectionResponseFormDefinitionBaseForwardPagingResultsInner'; +import { DatepickerField } from '../models/DatepickerField'; +import { DependentField } from '../models/DependentField'; +import { DependentFieldDependentField } from '../models/DependentFieldDependentField'; +import { DependentFieldFilter } from '../models/DependentFieldFilter'; +import { DropdownField } from '../models/DropdownField'; +import { EmailField } from '../models/EmailField'; +import { EmailFieldValidation } from '../models/EmailFieldValidation'; +import { EnumeratedFieldOption } from '../models/EnumeratedFieldOption'; +import { ErrorDetail } from '../models/ErrorDetail'; +import { FieldGroup } from '../models/FieldGroup'; +import { FileField } from '../models/FileField'; +import { FormDefinitionBase } from '../models/FormDefinitionBase'; +import { FormDefinitionCreateRequestBase } from '../models/FormDefinitionCreateRequestBase'; +import { FormDisplayOptions } from '../models/FormDisplayOptions'; +import { FormPostSubmitAction } from '../models/FormPostSubmitAction'; +import { FormStyle } from '../models/FormStyle'; +import { ForwardPaging } from '../models/ForwardPaging'; +import { HubSpotFormConfiguration } from '../models/HubSpotFormConfiguration'; +import { HubSpotFormDefinition } from '../models/HubSpotFormDefinition'; +import { HubSpotFormDefinitionAllOf } from '../models/HubSpotFormDefinitionAllOf'; +import { HubSpotFormDefinitionCreateRequest } from '../models/HubSpotFormDefinitionCreateRequest'; +import { HubSpotFormDefinitionCreateRequestAllOf } from '../models/HubSpotFormDefinitionCreateRequestAllOf'; +import { HubSpotFormDefinitionPatchRequest } from '../models/HubSpotFormDefinitionPatchRequest'; +import { HubSpotFormDefinitionPatchRequestLegalConsentOptions } from '../models/HubSpotFormDefinitionPatchRequestLegalConsentOptions'; +import { LegalConsentCheckbox } from '../models/LegalConsentCheckbox'; +import { LegalConsentOptionsExplicitConsentToProcess } from '../models/LegalConsentOptionsExplicitConsentToProcess'; +import { LegalConsentOptionsImplicitConsentToProcess } from '../models/LegalConsentOptionsImplicitConsentToProcess'; +import { LegalConsentOptionsLegitimateInterest } from '../models/LegalConsentOptionsLegitimateInterest'; +import { LegalConsentOptionsNone } from '../models/LegalConsentOptionsNone'; +import { MobilePhoneField } from '../models/MobilePhoneField'; +import { ModelError } from '../models/ModelError'; +import { MultiLineTextField } from '../models/MultiLineTextField'; +import { MultipleCheckboxesField } from '../models/MultipleCheckboxesField'; +import { NextPage } from '../models/NextPage'; +import { NumberField } from '../models/NumberField'; +import { NumberFieldValidation } from '../models/NumberFieldValidation'; +import { PaymentLinkRadioField } from '../models/PaymentLinkRadioField'; +import { PhoneField } from '../models/PhoneField'; +import { PhoneFieldValidation } from '../models/PhoneFieldValidation'; +import { RadioField } from '../models/RadioField'; +import { SingleCheckboxField } from '../models/SingleCheckboxField'; +import { SingleLineTextField } from '../models/SingleLineTextField'; + +import { FormsApiRequestFactory, FormsApiResponseProcessor} from "../apis/FormsApi"; +export class ObservableFormsApi { + private requestFactory: FormsApiRequestFactory; + private responseProcessor: FormsApiResponseProcessor; + private configuration: Configuration; + + public constructor( + configuration: Configuration, + requestFactory?: FormsApiRequestFactory, + responseProcessor?: FormsApiResponseProcessor + ) { + this.configuration = configuration; + this.requestFactory = requestFactory || new FormsApiRequestFactory(configuration); + this.responseProcessor = responseProcessor || new FormsApiResponseProcessor(); + } + + /** + * Archive a form definition. New submissions will not be accepted and the form definition will be permanently deleted after 3 months. + * Archive a form definition + * @param formId The ID of the form to archive. + */ + public archive(formId: string, _options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.archive(formId, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.archive(rsp))); + })); + } + + /** + * Add a new `hubspot` form + * Create a form + * @param formDefinitionCreateRequestBase + */ + public create(formDefinitionCreateRequestBase: FormDefinitionCreateRequestBase, _options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.create(formDefinitionCreateRequestBase, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.create(rsp))); + })); + } + + /** + * Returns a form based on the form ID provided. + * Get a form definition + * @param formId The unique identifier of the form + * @param archived Whether to return only results that have been archived. + */ + public getById(formId: string, archived?: boolean, _options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.getById(formId, archived, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getById(rsp))); + })); + } + + /** + * Returns a list of forms based on the search filters. By default, it returns the first 20 `hubspot` forms + * Get a list of forms + * @param after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. + * @param limit The maximum number of results to display per page. + * @param archived Whether to return only results that have been archived. + * @param formTypes The form types to be included in the results. + */ + public getPage(after?: string, limit?: number, archived?: boolean, formTypes?: Array<'hubspot' | 'captured' | 'flow' | 'blog_comment' | 'all'>, _options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.getPage(after, limit, archived, formTypes, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getPage(rsp))); + })); + } + + /** + * Update all fields of a hubspot form definition. + * Update a form definition + * @param formId + * @param hubSpotFormDefinition + */ + public replace(formId: string, hubSpotFormDefinition: HubSpotFormDefinition, _options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.replace(formId, hubSpotFormDefinition, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.replace(rsp))); + })); + } + + /** + * Update some of the form definition components + * Partially update a form definition + * @param formId The ID of the form to update. + * @param hubSpotFormDefinitionPatchRequest + */ + public update(formId: string, hubSpotFormDefinitionPatchRequest: HubSpotFormDefinitionPatchRequest, _options?: Configuration): Observable { + const requestContextPromise = this.requestFactory.update(formId, hubSpotFormDefinitionPatchRequest, _options); + + // build promise chain + let middlewarePreObservable = from(requestContextPromise); + for (let middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx))); + } + + return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))). + pipe(mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (let middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp))); + } + return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.update(rsp))); + })); + } + +} diff --git a/codegen/marketing/forms/types/PromiseAPI.ts b/codegen/marketing/forms/types/PromiseAPI.ts new file mode 100644 index 000000000..6dd809ef5 --- /dev/null +++ b/codegen/marketing/forms/types/PromiseAPI.ts @@ -0,0 +1,132 @@ +import { ResponseContext, RequestContext, HttpFile } from '../http/http'; +import { Configuration} from '../configuration' + +import { CollectionResponseFormDefinitionBaseForwardPaging } from '../models/CollectionResponseFormDefinitionBaseForwardPaging'; +import { CollectionResponseFormDefinitionBaseForwardPagingResultsInner } from '../models/CollectionResponseFormDefinitionBaseForwardPagingResultsInner'; +import { DatepickerField } from '../models/DatepickerField'; +import { DependentField } from '../models/DependentField'; +import { DependentFieldDependentField } from '../models/DependentFieldDependentField'; +import { DependentFieldFilter } from '../models/DependentFieldFilter'; +import { DropdownField } from '../models/DropdownField'; +import { EmailField } from '../models/EmailField'; +import { EmailFieldValidation } from '../models/EmailFieldValidation'; +import { EnumeratedFieldOption } from '../models/EnumeratedFieldOption'; +import { ErrorDetail } from '../models/ErrorDetail'; +import { FieldGroup } from '../models/FieldGroup'; +import { FileField } from '../models/FileField'; +import { FormDefinitionBase } from '../models/FormDefinitionBase'; +import { FormDefinitionCreateRequestBase } from '../models/FormDefinitionCreateRequestBase'; +import { FormDisplayOptions } from '../models/FormDisplayOptions'; +import { FormPostSubmitAction } from '../models/FormPostSubmitAction'; +import { FormStyle } from '../models/FormStyle'; +import { ForwardPaging } from '../models/ForwardPaging'; +import { HubSpotFormConfiguration } from '../models/HubSpotFormConfiguration'; +import { HubSpotFormDefinition } from '../models/HubSpotFormDefinition'; +import { HubSpotFormDefinitionAllOf } from '../models/HubSpotFormDefinitionAllOf'; +import { HubSpotFormDefinitionCreateRequest } from '../models/HubSpotFormDefinitionCreateRequest'; +import { HubSpotFormDefinitionCreateRequestAllOf } from '../models/HubSpotFormDefinitionCreateRequestAllOf'; +import { HubSpotFormDefinitionPatchRequest } from '../models/HubSpotFormDefinitionPatchRequest'; +import { HubSpotFormDefinitionPatchRequestLegalConsentOptions } from '../models/HubSpotFormDefinitionPatchRequestLegalConsentOptions'; +import { LegalConsentCheckbox } from '../models/LegalConsentCheckbox'; +import { LegalConsentOptionsExplicitConsentToProcess } from '../models/LegalConsentOptionsExplicitConsentToProcess'; +import { LegalConsentOptionsImplicitConsentToProcess } from '../models/LegalConsentOptionsImplicitConsentToProcess'; +import { LegalConsentOptionsLegitimateInterest } from '../models/LegalConsentOptionsLegitimateInterest'; +import { LegalConsentOptionsNone } from '../models/LegalConsentOptionsNone'; +import { MobilePhoneField } from '../models/MobilePhoneField'; +import { ModelError } from '../models/ModelError'; +import { MultiLineTextField } from '../models/MultiLineTextField'; +import { MultipleCheckboxesField } from '../models/MultipleCheckboxesField'; +import { NextPage } from '../models/NextPage'; +import { NumberField } from '../models/NumberField'; +import { NumberFieldValidation } from '../models/NumberFieldValidation'; +import { PaymentLinkRadioField } from '../models/PaymentLinkRadioField'; +import { PhoneField } from '../models/PhoneField'; +import { PhoneFieldValidation } from '../models/PhoneFieldValidation'; +import { RadioField } from '../models/RadioField'; +import { SingleCheckboxField } from '../models/SingleCheckboxField'; +import { SingleLineTextField } from '../models/SingleLineTextField'; +import { ObservableFormsApi } from './ObservableAPI'; + +import { FormsApiRequestFactory, FormsApiResponseProcessor} from "../apis/FormsApi"; +export class PromiseFormsApi { + private api: ObservableFormsApi + + public constructor( + configuration: Configuration, + requestFactory?: FormsApiRequestFactory, + responseProcessor?: FormsApiResponseProcessor + ) { + this.api = new ObservableFormsApi(configuration, requestFactory, responseProcessor); + } + + /** + * Archive a form definition. New submissions will not be accepted and the form definition will be permanently deleted after 3 months. + * Archive a form definition + * @param formId The ID of the form to archive. + */ + public archive(formId: string, _options?: Configuration): Promise { + const result = this.api.archive(formId, _options); + return result.toPromise(); + } + + /** + * Add a new `hubspot` form + * Create a form + * @param formDefinitionCreateRequestBase + */ + public create(formDefinitionCreateRequestBase: FormDefinitionCreateRequestBase, _options?: Configuration): Promise { + const result = this.api.create(formDefinitionCreateRequestBase, _options); + return result.toPromise(); + } + + /** + * Returns a form based on the form ID provided. + * Get a form definition + * @param formId The unique identifier of the form + * @param archived Whether to return only results that have been archived. + */ + public getById(formId: string, archived?: boolean, _options?: Configuration): Promise { + const result = this.api.getById(formId, archived, _options); + return result.toPromise(); + } + + /** + * Returns a list of forms based on the search filters. By default, it returns the first 20 `hubspot` forms + * Get a list of forms + * @param after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. + * @param limit The maximum number of results to display per page. + * @param archived Whether to return only results that have been archived. + * @param formTypes The form types to be included in the results. + */ + public getPage(after?: string, limit?: number, archived?: boolean, formTypes?: Array<'hubspot' | 'captured' | 'flow' | 'blog_comment' | 'all'>, _options?: Configuration): Promise { + const result = this.api.getPage(after, limit, archived, formTypes, _options); + return result.toPromise(); + } + + /** + * Update all fields of a hubspot form definition. + * Update a form definition + * @param formId + * @param hubSpotFormDefinition + */ + public replace(formId: string, hubSpotFormDefinition: HubSpotFormDefinition, _options?: Configuration): Promise { + const result = this.api.replace(formId, hubSpotFormDefinition, _options); + return result.toPromise(); + } + + /** + * Update some of the form definition components + * Partially update a form definition + * @param formId The ID of the form to update. + * @param hubSpotFormDefinitionPatchRequest + */ + public update(formId: string, hubSpotFormDefinitionPatchRequest: HubSpotFormDefinitionPatchRequest, _options?: Configuration): Promise { + const result = this.api.update(formId, hubSpotFormDefinitionPatchRequest, _options); + return result.toPromise(); + } + + +} + + + diff --git a/codegen/marketing/forms/util.ts b/codegen/marketing/forms/util.ts new file mode 100644 index 000000000..96ea3dfdc --- /dev/null +++ b/codegen/marketing/forms/util.ts @@ -0,0 +1,37 @@ +/** + * Returns if a specific http code is in a given code range + * where the code range is defined as a combination of digits + * and "X" (the letter X) with a length of 3 + * + * @param codeRange string with length 3 consisting of digits and "X" (the letter X) + * @param code the http status code to be checked against the code range + */ +export function isCodeInRange(codeRange: string, code: number): boolean { + // This is how the default value is encoded in OAG + if (codeRange === "0") { + return true; + } + if (codeRange == code.toString()) { + return true; + } else { + const codeString = code.toString(); + if (codeString.length != codeRange.length) { + return false; + } + for (let i = 0; i < codeString.length; i++) { + if (codeRange.charAt(i) != "X" && codeRange.charAt(i) != codeString.charAt(i)) { + return false; + } + } + return true; + } +} + +/** +* Returns if it can consume form +* +* @param consumes array +*/ +export function canConsumeForm(contentTypes: string[]): boolean { + return contentTypes.indexOf('multipart/form-data') !== -1 +} diff --git a/src/discovery/marketing/MarketingDiscovery.ts b/src/discovery/marketing/MarketingDiscovery.ts index 2c0881452..e8cb76534 100644 --- a/src/discovery/marketing/MarketingDiscovery.ts +++ b/src/discovery/marketing/MarketingDiscovery.ts @@ -1,9 +1,11 @@ import BaseDiscovery from '../BaseDiscovery' import type EventsDiscovery from './events/EventsDiscovery' +import type FormsDiscovery from './forms/FormsDiscovery' import type TransactionalDiscovery from './transactional/TransactionalDiscovery' export default class MarketingDiscovery extends BaseDiscovery { protected _events: EventsDiscovery | undefined + protected _forms: FormsDiscovery | undefined protected _transactional: TransactionalDiscovery | undefined /** @@ -19,6 +21,19 @@ export default class MarketingDiscovery extends BaseDiscovery { return this._events } + /** + * Getter + * @returns FormsDiscovery + */ + get forms() { + if (!this._forms) { + const requiredClass = require('./forms/FormsDiscovery') + this._forms = new requiredClass.default(this.config) as FormsDiscovery + } + + return this._forms + } + /** * Getter * @returns TransactionalDiscovery diff --git a/src/discovery/marketing/forms/FormsDiscovery.ts b/src/discovery/marketing/forms/FormsDiscovery.ts new file mode 100644 index 000000000..5617efba8 --- /dev/null +++ b/src/discovery/marketing/forms/FormsDiscovery.ts @@ -0,0 +1,29 @@ +import { + createConfiguration, + FormsApi, + RequestContext, + ResponseContext, + ServerConfiguration, +} from '../../../../codegen/marketing/forms/index' +import { Observable } from '../../../../codegen/marketing/forms/rxjsStub' +import { ApiClientConfigurator } from '../../../configuration/ApiClientConfigurator' +import IConfiguration from '../../../configuration/IConfiguration' +import ApiDecoratorService from '../../../services/ApiDecoratorService' + +export default class FormsDiscovery { + public formsApi: FormsApi + + constructor(config: IConfiguration) { + const configuration = createConfiguration( + ApiClientConfigurator.getParams< + RequestContext, + ResponseContext, + Observable, + Observable, + ServerConfiguration<{}> + >(config, ServerConfiguration, Observable, Observable), + ) + + this.formsApi = ApiDecoratorService.getInstance().apply(new FormsApi(configuration)) + } +} diff --git a/test/spec/marketing/forms/forms.spec.ts b/test/spec/marketing/forms/forms.spec.ts new file mode 100644 index 000000000..0186b1ae4 --- /dev/null +++ b/test/spec/marketing/forms/forms.spec.ts @@ -0,0 +1,8 @@ +import { Client } from '../../../../index' + +describe('api client', () => { + it('is discoverable', () => { + const client = new Client().marketing.forms + expect(client.hasOwnProperty('formsApi')).toBeTruthy() + }) +}) diff --git a/test/spec/marketing/marketing.spec.ts b/test/spec/marketing/marketing.spec.ts index 4ef12e29b..03178318d 100644 --- a/test/spec/marketing/marketing.spec.ts +++ b/test/spec/marketing/marketing.spec.ts @@ -1,11 +1,13 @@ import { Client } from '../../../index' import EventsDiscovery from '../../../src/discovery/marketing/events/EventsDiscovery' +import FormsDiscovery from '../../../src/discovery/marketing/forms/FormsDiscovery' import TransactionalDiscovery from '../../../src/discovery/marketing/transactional/TransactionalDiscovery' describe('api client', () => { it('is discoverable', () => { const client = new Client().marketing expect(EventsDiscovery.name).toBe(client.events.constructor.name) + expect(FormsDiscovery.name).toBe(client.forms.constructor.name) expect(TransactionalDiscovery.name).toBe(client.transactional.constructor.name) }) })