@aloma.io/integration-sdk 3.8.54 → 3.8.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/MULTI_RESOURCE_GUIDE.md +24 -21
  2. package/OPENAPI_TO_CONNECTOR.md +146 -16
  3. package/README.md +62 -10
  4. package/build/cli.mjs +122 -33
  5. package/build/openapi-to-connector.d.mts +92 -11
  6. package/build/openapi-to-connector.mjs +968 -168
  7. package/package.json +3 -1
  8. package/src/cli.mts +140 -37
  9. package/src/openapi-to-connector.mts +1092 -176
  10. package/test/scenarios/README.md +148 -0
  11. package/test/scenarios/complex/expected/controller.mts +271 -0
  12. package/test/scenarios/complex/expected/orders-resource.mts +264 -0
  13. package/test/scenarios/complex/expected/products-resource.mts +239 -0
  14. package/test/scenarios/complex/specs/orders.json +362 -0
  15. package/test/scenarios/complex/specs/products.json +308 -0
  16. package/test/scenarios/simple/expected-controller.mts +60 -0
  17. package/test/scenarios/simple/simple-api.json +39 -0
  18. package/test/scenarios.test.mts +286 -0
  19. package/test/verify-scenarios.mjs +298 -0
  20. package/examples/api-without-servers.json +0 -32
  21. package/examples/companies-resource-class.mts +0 -310
  22. package/examples/companies-resource.mts +0 -310
  23. package/examples/complete-example.sh +0 -116
  24. package/examples/create-hubspot-connector.sh +0 -33
  25. package/examples/generate-connector.sh +0 -35
  26. package/examples/generated-controller.mts +0 -81
  27. package/examples/hubspot-companies.json +0 -1889
  28. package/examples/hubspot-contacts.json +0 -1919
  29. package/examples/hubspot-controller-individual-params.mts +0 -323
  30. package/examples/hubspot-controller-with-implementation.mts +0 -315
  31. package/examples/hubspot-controller.mts +0 -192
  32. package/examples/hubspot-lists.json +0 -5525
  33. package/examples/main-controller-with-resources.mts +0 -35
  34. package/examples/stripe.json +0 -182829
  35. package/examples/utility-click.json +0 -8992
@@ -0,0 +1,298 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import { OpenAPIToConnector } from '../build/openapi-to-connector.mjs';
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+
9
+ // Colors for output
10
+ const colors = {
11
+ green: '\x1b[32m',
12
+ red: '\x1b[31m',
13
+ yellow: '\x1b[33m',
14
+ reset: '\x1b[0m',
15
+ cyan: '\x1b[36m'
16
+ };
17
+
18
+ let passed = 0;
19
+ let failed = 0;
20
+
21
+ function test(name, fn) {
22
+ try {
23
+ console.log(`${colors.cyan}Running: ${name}${colors.reset}`);
24
+ fn();
25
+ console.log(`${colors.green}✓ PASS: ${name}${colors.reset}\n`);
26
+ passed++;
27
+ } catch (error) {
28
+ console.log(`${colors.red}✗ FAIL: ${name}${colors.reset}`);
29
+ console.log(`${colors.red} Error: ${error.message}${colors.reset}\n`);
30
+ failed++;
31
+ }
32
+ }
33
+
34
+ function expect(actual) {
35
+ return {
36
+ toEqual: (expected) => {
37
+ if (actual !== expected) {
38
+ throw new Error(`Expected:\n${expected.slice(0, 200)}...\n\nActual:\n${actual.slice(0, 200)}...`);
39
+ }
40
+ },
41
+ toInclude: (expected) => {
42
+ if (!actual.includes(expected)) {
43
+ throw new Error(`Expected output to include: "${expected}"\n\nActual output snippet: "${actual.slice(0, 500)}..."`);
44
+ }
45
+ },
46
+ toNotInclude: (expected) => {
47
+ if (actual.includes(expected)) {
48
+ throw new Error(`Expected output to NOT include: "${expected}"\n\nBut it was found in the output.`);
49
+ }
50
+ }
51
+ };
52
+ }
53
+
54
+ // Helper function to normalize output
55
+ const normalizeOutput = (output) => output
56
+ .replace(/\r\n/g, '\n')
57
+ .trim();
58
+
59
+ console.log(`${colors.yellow}🧪 Running Scenario Fixture Tests${colors.reset}\n`);
60
+
61
+ // Test 1: Simple Scenario
62
+ test('Simple Scenario - should generate expected output', () => {
63
+ // Read input spec
64
+ const specPath = path.join(__dirname, 'scenarios/simple/simple-api.json');
65
+ const specContent = fs.readFileSync(specPath, 'utf-8');
66
+ const spec = OpenAPIToConnector.parseSpec(specContent);
67
+
68
+ // Read expected output
69
+ const expectedPath = path.join(__dirname, 'scenarios/simple/expected-controller.mts');
70
+ const expectedOutput = fs.readFileSync(expectedPath, 'utf-8');
71
+
72
+ // Generate actual output
73
+ const generator = new OpenAPIToConnector(spec, 'simple-test');
74
+ const actualOutput = generator.generateController();
75
+
76
+ // Compare outputs
77
+ expect(normalizeOutput(actualOutput)).toEqual(normalizeOutput(expectedOutput));
78
+ });
79
+
80
+ // Test 2: Simple Scenario - Methods without options
81
+ test('Simple Scenario - methods without options should be clean', () => {
82
+ const specPath = path.join(__dirname, 'scenarios/simple/simple-api.json');
83
+ const specContent = fs.readFileSync(specPath, 'utf-8');
84
+ const spec = OpenAPIToConnector.parseSpec(specContent);
85
+
86
+ const generator = new OpenAPIToConnector(spec, 'simple-test');
87
+ const actualOutput = generator.generateController();
88
+
89
+ expect(actualOutput).toInclude('async getProducts() {');
90
+ expect(actualOutput).toInclude('async createProduct(options:');
91
+ });
92
+
93
+ // Test 3: Complex Scenario - Main Controller
94
+ test('Complex Scenario - main controller should generate expected output', () => {
95
+ const productsSpecPath = path.join(__dirname, 'scenarios/complex/specs/products.json');
96
+ const ordersSpecPath = path.join(__dirname, 'scenarios/complex/specs/orders.json');
97
+ const productsSpecContent = fs.readFileSync(productsSpecPath, 'utf-8');
98
+ const ordersSpecContent = fs.readFileSync(ordersSpecPath, 'utf-8');
99
+
100
+ const productsSpec = OpenAPIToConnector.parseSpec(productsSpecContent);
101
+ const ordersSpec = OpenAPIToConnector.parseSpec(ordersSpecContent);
102
+
103
+ const expectedPath = path.join(__dirname, 'scenarios/complex/expected/controller.mts');
104
+ const expectedOutput = fs.readFileSync(expectedPath, 'utf-8');
105
+
106
+ const resources = [
107
+ { className: 'ProductsResource', fileName: 'products' },
108
+ { className: 'OrdersResource', fileName: 'orders' }
109
+ ];
110
+ const resourceSpecs = [
111
+ { fileName: 'products', spec: productsSpec },
112
+ { fileName: 'orders', spec: ordersSpec }
113
+ ];
114
+
115
+ const mainGenerator = new OpenAPIToConnector(productsSpec, 'test-shop-temp');
116
+ const actualOutput = mainGenerator.generateMainController(resources, resourceSpecs);
117
+
118
+ expect(normalizeOutput(actualOutput)).toEqual(normalizeOutput(expectedOutput));
119
+ });
120
+
121
+ // Test 4: Complex Scenario - Products Resource
122
+ test('Complex Scenario - products resource should generate expected output', () => {
123
+ const specPath = path.join(__dirname, 'scenarios/complex/specs/products.json');
124
+ const specContent = fs.readFileSync(specPath, 'utf-8');
125
+ const spec = OpenAPIToConnector.parseSpec(specContent);
126
+
127
+ const expectedPath = path.join(__dirname, 'scenarios/complex/expected/products-resource.mts');
128
+ const expectedOutput = fs.readFileSync(expectedPath, 'utf-8');
129
+
130
+ const generator = new OpenAPIToConnector(spec, 'test-shop');
131
+ const actualOutput = generator.generateResourceClass('ProductsResource');
132
+
133
+ expect(normalizeOutput(actualOutput)).toEqual(normalizeOutput(expectedOutput));
134
+ });
135
+
136
+ // Test 5: Complex Scenario - Orders Resource
137
+ test('Complex Scenario - orders resource should generate expected output', () => {
138
+ const specPath = path.join(__dirname, 'scenarios/complex/specs/orders.json');
139
+ const specContent = fs.readFileSync(specPath, 'utf-8');
140
+ const spec = OpenAPIToConnector.parseSpec(specContent);
141
+
142
+ const expectedPath = path.join(__dirname, 'scenarios/complex/expected/orders-resource.mts');
143
+ const expectedOutput = fs.readFileSync(expectedPath, 'utf-8');
144
+
145
+ const generator = new OpenAPIToConnector(spec, 'test-shop');
146
+ const actualOutput = generator.generateResourceClass('OrdersResource');
147
+
148
+ expect(normalizeOutput(actualOutput)).toEqual(normalizeOutput(expectedOutput));
149
+ });
150
+
151
+ // Test 6: TypeScript Interface Generation
152
+ test('TypeScript interfaces should be generated correctly', () => {
153
+ const specPath = path.join(__dirname, 'scenarios/complex/specs/products.json');
154
+ const specContent = fs.readFileSync(specPath, 'utf-8');
155
+ const spec = OpenAPIToConnector.parseSpec(specContent);
156
+
157
+ const generator = new OpenAPIToConnector(spec, 'test-shop');
158
+ const actualOutput = generator.generateResourceClass('ProductsResource');
159
+
160
+ expect(actualOutput).toInclude('export interface Product {');
161
+ expect(actualOutput).toInclude('export interface ProductList {');
162
+ expect(actualOutput).toInclude('export interface CreateProductRequest {');
163
+ expect(actualOutput).toInclude('Promise<ProductList>');
164
+ expect(actualOutput).toInclude('Promise<Product>');
165
+ });
166
+
167
+ // Test 7: Path Parameters and Options
168
+ test('Path parameters and options should be handled correctly', () => {
169
+ const specPath = path.join(__dirname, 'scenarios/complex/specs/orders.json');
170
+ const specContent = fs.readFileSync(specPath, 'utf-8');
171
+ const spec = OpenAPIToConnector.parseSpec(specContent);
172
+
173
+ const generator = new OpenAPIToConnector(spec, 'test-shop');
174
+ const actualOutput = generator.generateResourceClass('OrdersResource');
175
+
176
+ expect(actualOutput).toInclude('export function getOrder(this: any, orderId: string)');
177
+ expect(actualOutput).toInclude('export function updateOrderStatus(this: any, orderId: string, options');
178
+ expect(actualOutput).toInclude('export function cancelOrder(this: any, orderId: string)');
179
+ });
180
+
181
+ // Test 8: Exposed Methods in Main Controller
182
+ test('Exposed methods should be present in main controller', () => {
183
+ const productsSpecPath = path.join(__dirname, 'scenarios/complex/specs/products.json');
184
+ const ordersSpecPath = path.join(__dirname, 'scenarios/complex/specs/orders.json');
185
+ const productsSpecContent = fs.readFileSync(productsSpecPath, 'utf-8');
186
+ const ordersSpecContent = fs.readFileSync(ordersSpecPath, 'utf-8');
187
+
188
+ const productsSpec = OpenAPIToConnector.parseSpec(productsSpecContent);
189
+ const ordersSpec = OpenAPIToConnector.parseSpec(ordersSpecContent);
190
+
191
+ const resources = [
192
+ { className: 'ProductsResource', fileName: 'products' },
193
+ { className: 'OrdersResource', fileName: 'orders' }
194
+ ];
195
+ const resourceSpecs = [
196
+ { fileName: 'products', spec: productsSpec },
197
+ { fileName: 'orders', spec: ordersSpec }
198
+ ];
199
+
200
+ const mainGenerator = new OpenAPIToConnector(productsSpec, 'test-shop');
201
+ const actualOutput = mainGenerator.generateMainController(resources, resourceSpecs);
202
+
203
+ expect(actualOutput).toInclude('async productsGetProducts(');
204
+ expect(actualOutput).toInclude('async productsCreateProduct(');
205
+ expect(actualOutput).toInclude('async productsGetProduct(');
206
+ expect(actualOutput).toInclude('async productsUpdateProduct(');
207
+ expect(actualOutput).toInclude('async productsDeleteProduct(');
208
+
209
+ expect(actualOutput).toInclude('async ordersGetOrders(');
210
+ expect(actualOutput).toInclude('async ordersCreateOrder(');
211
+ expect(actualOutput).toInclude('async ordersGetOrder(');
212
+ expect(actualOutput).toInclude('async ordersUpdateOrderStatus(');
213
+ expect(actualOutput).toInclude('async ordersCancelOrder(');
214
+
215
+ expect(actualOutput).toInclude('this.bindResourceFunctions(\'products\', productsFunctions);');
216
+ expect(actualOutput).toInclude('this.bindResourceFunctions(\'orders\', ordersFunctions);');
217
+ });
218
+
219
+ // Test 9: Schema Name Sanitization
220
+ test('Schema names should be sanitized correctly', () => {
221
+ const testSpec = {
222
+ openapi: '3.0.0',
223
+ info: { title: 'Test API', version: '1.0.0' },
224
+ paths: {
225
+ '/test': {
226
+ get: {
227
+ operationId: 'testOperation',
228
+ responses: {
229
+ '200': {
230
+ description: 'Success',
231
+ content: {
232
+ 'application/json': {
233
+ schema: {
234
+ '$ref': '#/components/schemas/Complex.Name.With.Dots'
235
+ }
236
+ }
237
+ }
238
+ }
239
+ }
240
+ }
241
+ }
242
+ },
243
+ components: {
244
+ schemas: {
245
+ 'Complex.Name.With.Dots': {
246
+ type: 'object',
247
+ properties: {
248
+ id: { type: 'string' },
249
+ name: { type: 'string' }
250
+ }
251
+ }
252
+ }
253
+ }
254
+ };
255
+
256
+ const generator = new OpenAPIToConnector(testSpec, 'test');
257
+ const output = generator.generateController();
258
+
259
+ expect(output).toInclude('export interface Complex_Name_With_Dots {');
260
+ expect(output).toNotInclude('export interface Complex.Name.With.Dots {');
261
+ expect(output).toInclude('Promise<Complex_Name_With_Dots>');
262
+ });
263
+
264
+ // Test 10: No Options Parameter for Simple Methods
265
+ test('Simple methods should not have options parameter', () => {
266
+ const simpleSpec = {
267
+ openapi: '3.0.0',
268
+ info: { title: 'Simple API', version: '1.0.0' },
269
+ paths: {
270
+ '/simple': {
271
+ get: {
272
+ operationId: 'getSimple',
273
+ responses: { '200': { description: 'Success' } }
274
+ }
275
+ }
276
+ }
277
+ };
278
+
279
+ const generator = new OpenAPIToConnector(simpleSpec, 'test');
280
+ const output = generator.generateController();
281
+
282
+ expect(output).toInclude('async getSimple() {');
283
+ expect(output).toNotInclude('options = options || {}');
284
+ expect(output).toNotInclude('headers: options');
285
+ });
286
+
287
+ // Print final results
288
+ console.log(`${colors.yellow}📊 Test Results:${colors.reset}`);
289
+ console.log(`${colors.green}✓ Passed: ${passed}${colors.reset}`);
290
+ console.log(`${colors.red}✗ Failed: ${failed}${colors.reset}`);
291
+
292
+ if (failed === 0) {
293
+ console.log(`\n${colors.green}🎉 All tests passed!${colors.reset}`);
294
+ process.exit(0);
295
+ } else {
296
+ console.log(`\n${colors.red}❌ Some tests failed!${colors.reset}`);
297
+ process.exit(1);
298
+ }
@@ -1,32 +0,0 @@
1
- {
2
- "openapi": "3.0.0",
3
- "info": {
4
- "title": "Test API",
5
- "version": "1.0.0",
6
- "description": "API without servers definition"
7
- },
8
- "paths": {
9
- "/users": {
10
- "get": {
11
- "summary": "List users",
12
- "operationId": "listUsers",
13
- "parameters": [
14
- {
15
- "name": "limit",
16
- "in": "query",
17
- "schema": {
18
- "type": "integer"
19
- },
20
- "description": "Maximum number of users"
21
- }
22
- ],
23
- "responses": {
24
- "200": {
25
- "description": "Success"
26
- }
27
- }
28
- }
29
- }
30
- }
31
- }
32
-
@@ -1,310 +0,0 @@
1
- import {AbstractController} from '@aloma.io/integration-sdk';
2
-
3
- export default class CompaniesResource extends AbstractController {
4
-
5
- /**
6
- * Retrieve a batch of companies
7
- *
8
- * Retrieve a batch of companies by ID (`companyId`) or by a unique property (`idProperty`). You can specify what is returned using the `properties` query parameter.
9
- *
10
- * @param {boolean} archived (optional) - Whether to return only results that have been archived. [query]
11
- *
12
- * @param {Object} body (required) - Request body
13
- *
14
- * @returns {Promise<Object>} POST /crm/v3/objects/companies/batch/read response
15
- */
16
- async read(archived?: any, body?: any) {
17
- const url = '/crm/v3/objects/companies/batch/read';
18
- const options: any = {
19
- method: 'POST',
20
- params: {},
21
- body,
22
- };
23
-
24
- // Add query parameters
25
- if (archived !== undefined) {
26
- options.params.archived = archived;
27
- }
28
-
29
- return this.api.fetch(url, options);
30
- }
31
-
32
- /**
33
- * Retrieve companies
34
- *
35
- * Retrieve all companies, using query parameters to control the information that gets returned.
36
- *
37
- * @param {integer} limit (optional) - The maximum number of results to display per page. [query]
38
- * @param {string} after (optional) - 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. [query]
39
- * @param {array} properties (optional) - A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored. [query]
40
- * @param {array} propertiesWithHistory (optional) - A comma separated list of the properties to be returned along with their history of previous values. If any of the specified properties are not present on the requested object(s), they will be ignored. Usage of this parameter will reduce the maximum number of companies that can be read by a single request. [query]
41
- * @param {array} associations (optional) - A comma separated list of object types to retrieve associated IDs for. If any of the specified associations do not exist, they will be ignored. [query]
42
- * @param {boolean} archived (optional) - Whether to return only results that have been archived. [query]
43
- *
44
- * @returns {Promise<Object>} GET /crm/v3/objects/companies response
45
- */
46
- async getPage(limit?: any, after?: any, properties?: any, propertiesWithHistory?: any, associations?: any, archived?: any) {
47
- const url = '/crm/v3/objects/companies';
48
- const options: any = {
49
- method: 'GET',
50
- params: {},
51
- };
52
-
53
- // Add query parameters
54
- if (limit !== undefined) {
55
- options.params.limit = limit;
56
- }
57
- if (after !== undefined) {
58
- options.params.after = after;
59
- }
60
- if (properties !== undefined) {
61
- options.params.properties = properties;
62
- }
63
- if (propertiesWithHistory !== undefined) {
64
- options.params.propertiesWithHistory = propertiesWithHistory;
65
- }
66
- if (associations !== undefined) {
67
- options.params.associations = associations;
68
- }
69
- if (archived !== undefined) {
70
- options.params.archived = archived;
71
- }
72
-
73
- return this.api.fetch(url, options);
74
- }
75
-
76
- /**
77
- * Create a company
78
- *
79
- * Create a single company. Include a `properties` object to define [property values](https://developers.hubspot.com/docs/guides/api/crm/properties) for the company, along with an `associations` array to define [associations](https://developers.hubspot.com/docs/guides/api/crm/associations/associations-v4) with other CRM records.
80
- *
81
- * @param {Object} body (required) - Request body
82
- *
83
- * @returns {Promise<Object>} POST /crm/v3/objects/companies response
84
- */
85
- async create(body?: any) {
86
- const url = '/crm/v3/objects/companies';
87
- const options: any = {
88
- method: 'POST',
89
- body,
90
- };
91
-
92
- return this.api.fetch(url, options);
93
- }
94
-
95
- /**
96
- * Search for companies
97
- *
98
- * Search for companies by filtering on properties, searching through associations, and sorting results. Learn more about [CRM search](https://developers.hubspot.com/docs/guides/api/crm/search#make-a-search-request).
99
- *
100
- * @param {Object} body (required) - Request body
101
- *
102
- * @returns {Promise<Object>} POST /crm/v3/objects/companies/search response
103
- */
104
- async doSearch(body?: any) {
105
- const url = '/crm/v3/objects/companies/search';
106
- const options: any = {
107
- method: 'POST',
108
- body,
109
- };
110
-
111
- return this.api.fetch(url, options);
112
- }
113
-
114
- /**
115
- * Retrieve a company
116
- *
117
- * Retrieve a company by its ID (`companyId`) or by a unique property (`idProperty`). You can specify what is returned using the `properties` query parameter.
118
- *
119
- * @param {string} companyId (required) - The ID of the company [path]
120
- * @param {array} properties (optional) - A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored. [query]
121
- * @param {array} propertiesWithHistory (optional) - A comma separated list of the properties to be returned along with their history of previous values. If any of the specified properties are not present on the requested object(s), they will be ignored. [query]
122
- * @param {array} associations (optional) - A comma separated list of object types to retrieve associated IDs for. If any of the specified associations do not exist, they will be ignored. [query]
123
- * @param {boolean} archived (optional) - Whether to return only results that have been archived. [query]
124
- * @param {string} idProperty (optional) - The name of a property whose values are unique for this object [query]
125
- *
126
- * @returns {Promise<Object>} GET /crm/v3/objects/companies/{companyId} response
127
- */
128
- async getById(companyId: string, properties?: any, propertiesWithHistory?: any, associations?: any, archived?: any, idProperty?: any) {
129
- // Build URL with path parameters
130
- let url = '/crm/v3/objects/companies/{companyId}';
131
- if (companyId) {
132
- url = url.replace('{companyId}', companyId);
133
- }
134
-
135
- const options: any = {
136
- method: 'GET',
137
- params: {},
138
- };
139
-
140
- // Add query parameters
141
- if (properties !== undefined) {
142
- options.params.properties = properties;
143
- }
144
- if (propertiesWithHistory !== undefined) {
145
- options.params.propertiesWithHistory = propertiesWithHistory;
146
- }
147
- if (associations !== undefined) {
148
- options.params.associations = associations;
149
- }
150
- if (archived !== undefined) {
151
- options.params.archived = archived;
152
- }
153
- if (idProperty !== undefined) {
154
- options.params.idProperty = idProperty;
155
- }
156
-
157
- return this.api.fetch(url, options);
158
- }
159
-
160
- /**
161
- * Update a company
162
- *
163
- * Update a company by ID (`companyId`) or unique property value (`idProperty`). Provided property values will be overwritten. Read-only and non-existent properties will result in an error. Properties values can be cleared by passing an empty string.
164
- *
165
- * @param {string} companyId (required) [path]
166
- * @param {string} idProperty (optional) - The name of a property whose values are unique for this object [query]
167
- *
168
- * @param {Object} body (required) - Request body
169
- *
170
- * @returns {Promise<Object>} PATCH /crm/v3/objects/companies/{companyId} response
171
- */
172
- async update(companyId: string, idProperty?: any, body?: any) {
173
- // Build URL with path parameters
174
- let url = '/crm/v3/objects/companies/{companyId}';
175
- if (companyId) {
176
- url = url.replace('{companyId}', companyId);
177
- }
178
-
179
- const options: any = {
180
- method: 'PATCH',
181
- params: {},
182
- body,
183
- };
184
-
185
- // Add query parameters
186
- if (idProperty !== undefined) {
187
- options.params.idProperty = idProperty;
188
- }
189
-
190
- return this.api.fetch(url, options);
191
- }
192
-
193
- /**
194
- * Archive a company
195
- *
196
- * Delete a company by ID. Deleted companies can be restored within 90 days of deletion. Learn more about [restoring records](https://knowledge.hubspot.com/records/restore-deleted-records).
197
- *
198
- * @param {string} companyId (required) [path]
199
- *
200
- * @returns {Promise<Object>} DELETE /crm/v3/objects/companies/{companyId} response
201
- */
202
- async archive(companyId: string) {
203
- // Build URL with path parameters
204
- let url = '/crm/v3/objects/companies/{companyId}';
205
- if (companyId) {
206
- url = url.replace('{companyId}', companyId);
207
- }
208
-
209
- const options: any = {
210
- method: 'DELETE',
211
- };
212
-
213
- return this.api.fetch(url, options);
214
- }
215
-
216
- /**
217
- * Create or update a batch of companies by unique property values
218
- *
219
- * Create or update companies identified by a unique property value as specified by the `idProperty` query parameter. `idProperty` query param refers to a property whose values are unique for the object.
220
- *
221
- * @param {Object} body (required) - Request body
222
- *
223
- * @returns {Promise<Object>} POST /crm/v3/objects/companies/batch/upsert response
224
- */
225
- async upsert(body?: any) {
226
- const url = '/crm/v3/objects/companies/batch/upsert';
227
- const options: any = {
228
- method: 'POST',
229
- body,
230
- };
231
-
232
- return this.api.fetch(url, options);
233
- }
234
-
235
- /**
236
- * Create a batch of companies
237
- *
238
- * Create a batch of companies. The `inputs` array can contain a `properties` object to define property values for each company, along with an `associations` array to define [associations](https://developers.hubspot.com/docs/guides/api/crm/associations/associations-v4) with other CRM records.
239
- *
240
- * @param {Object} body (required) - Request body
241
- *
242
- * @returns {Promise<Object>} POST /crm/v3/objects/companies/batch/create response
243
- */
244
- async create(body?: any) {
245
- const url = '/crm/v3/objects/companies/batch/create';
246
- const options: any = {
247
- method: 'POST',
248
- body,
249
- };
250
-
251
- return this.api.fetch(url, options);
252
- }
253
-
254
- /**
255
- * Update a batch of companies
256
- *
257
- * Update a batch of companies by ID.
258
- *
259
- * @param {Object} body (required) - Request body
260
- *
261
- * @returns {Promise<Object>} POST /crm/v3/objects/companies/batch/update response
262
- */
263
- async update(body?: any) {
264
- const url = '/crm/v3/objects/companies/batch/update';
265
- const options: any = {
266
- method: 'POST',
267
- body,
268
- };
269
-
270
- return this.api.fetch(url, options);
271
- }
272
-
273
- /**
274
- * Archive a batch of companies
275
- *
276
- * Delete a batch of companies by ID. Deleted companies can be restored within 90 days of deletion. Learn more about [restoring records](https://knowledge.hubspot.com/records/restore-deleted-records).
277
- *
278
- * @param {Object} body (required) - Request body
279
- *
280
- * @returns {Promise<Object>} POST /crm/v3/objects/companies/batch/archive response
281
- */
282
- async archive(body?: any) {
283
- const url = '/crm/v3/objects/companies/batch/archive';
284
- const options: any = {
285
- method: 'POST',
286
- body,
287
- };
288
-
289
- return this.api.fetch(url, options);
290
- }
291
-
292
- /**
293
- * Merge two companies
294
- *
295
- * Merge two company records. Learn more about [merging records](https://knowledge.hubspot.com/records/merge-records).
296
- *
297
- * @param {Object} body (required) - Request body
298
- *
299
- * @returns {Promise<Object>} POST /crm/v3/objects/companies/merge response
300
- */
301
- async merge(body?: any) {
302
- const url = '/crm/v3/objects/companies/merge';
303
- const options: any = {
304
- method: 'POST',
305
- body,
306
- };
307
-
308
- return this.api.fetch(url, options);
309
- }
310
- }