Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions src/appmixer/hubspot/artifacts/test-flows/test-flow-make-api-call.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
{
"name": "E2E Hubspot - Make API Call",
"description": "End-to-end test for Hubspot connector - tests MakeApiCall component by performing a GET request to the HubSpot CRM contacts endpoint and validating the response.",
"flow": {
"on-start": {
"type": "appmixer.utils.controls.OnStart",
"x": 64,
"y": 16,
"source": {},
"version": "1.0.0",
"config": {}
},
"make-api-call": {
"type": "appmixer.hubspot.crm.MakeApiCall",
"x": 256,
"y": 16,
"version": "1.0.0",
"source": {
"in": {
"on-start": [
"out"
]
}
},
"config": {
"transform": {
"in": {
"on-start": {
"out": {
"type": "json2new",
"modifiers": {
"url": {},
"method": {}
},
"lambda": {
"url": "https://api.hubapi.com/crm/v3/objects/contacts",
"method": "GET"
}
}
}
}
}
}
},
"assert-status": {
"type": "appmixer.utils.test.Assert",
"x": 448,
"y": 16,
"version": "1.0.0",
"source": {
"in": {
"make-api-call": [
"out"
]
}
},
"config": {
"transform": {
"in": {
"make-api-call": {
"out": {
"type": "json2new",
"modifiers": {
"expression": {
"status-var": {
"variable": "$.make-api-call.out.status",
"functions": []
}
}
},
"lambda": {
"expression": {
"AND": [
{
"field": "{{{status-var}}}",
"assertion": "equal",
"expected": "200"
}
]
}
}
}
}
}
}
}
},
"assert-body": {
"type": "appmixer.utils.test.Assert",
"x": 448,
"y": 144,
"version": "1.0.0",
"source": {
"in": {
"make-api-call": [
"out"
]
}
},
"config": {
"transform": {
"in": {
"make-api-call": {
"out": {
"type": "json2new",
"modifiers": {
"expression": {
"body-var": {
"variable": "$.make-api-call.out.body",
"functions": []
}
}
},
"lambda": {
"expression": {
"AND": [
{
"field": "{{{body-var}}}",
"assertion": "notEmpty"
}
]
}
}
}
}
}
}
}
},
"after-all": {
"type": "appmixer.utils.test.AfterAll",
"x": 640,
"y": 80,
"version": "1.0.0",
"source": {
"in": {
"assert-status": [
"out"
],
"assert-body": [
"out"
]
}
},
"config": {
"properties": {
"timeout": 30
}
}
},
"process-results": {
"type": "appmixer.utils.test.ProcessE2EResults",
"x": 832,
"y": 80,
"version": "1.0.0",
"source": {
"in": {
"after-all": [
"out"
]
}
},
"config": {
"properties": {
"successStoreId": "64f6f1f9193228000754082f",
"failedStoreId": "64f6f1f0193228000754082e"
},
"transform": {
"in": {
"after-all": {
"out": {
"type": "json2new",
"modifiers": {
"recipients": {},
"testCase": {},
"result": {
"result-var": {
"variable": "$.after-all.out",
"functions": []
}
}
},
"lambda": {
"recipients": "jirka@client.io",
"testCase": "E2E Hubspot - Make API Call",
"result": "{{{result-var}}}"
}
}
}
}
}
}
}
}
}
7 changes: 5 additions & 2 deletions src/appmixer/hubspot/bundle.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appmixer.hubspot",
"version": "4.4.1",
"version": "4.4.2",
"engine": ">=6.0.0",
"changelog": {
"1.0.0": [
Expand Down Expand Up @@ -87,6 +87,9 @@
"Added optional Pipeline filter to NewDeal trigger.",
"Added Pipeline and Stage filter inputs to ListDeals action using CRM Search API filterGroups.",
"Replaced hard-coded deal stages in UpdateDeal action with dynamic ListPipelineStages cascade."
],
"4.4.2": [
"Added MakeApiCall component."
]
}
}
}
43 changes: 43 additions & 0 deletions src/appmixer/hubspot/crm/MakeApiCall/MakeApiCall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

module.exports = {

async receive(context) {

const { url, method, headers, parameters, body } = context.messages.in.content;

const requestOptions = {
method,
url,
headers: {
'Authorization': `Bearer ${context.auth.accessToken}`,
'Content-Type': 'application/json'
}
};

if (headers && headers.length > 0) {
headers.forEach(({ key, value }) => {
if (key) requestOptions.headers[key] = value;
});
}

if (parameters && parameters.length > 0) {
requestOptions.params = parameters.reduce((acc, { key, value }) => {
if (key) acc[key] = value;
return acc;
}, {});
}

if (body) {
requestOptions.data = JSON.parse(body);
}

const response = await context.httpRequest(requestOptions);

return context.sendJson({
status: response.status,
headers: response.headers,
body: response.data
}, 'out');
}
};
Loading
Loading