Skip to content

Lookup by #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from 12 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.1.0 (June 15, 2025)

* Added `Lookup Object By ID` Action

# 1.0.0 (June 03, 2025)

* Initial component release
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [Description](#description)
* [Credentials](#credentials)
* [Actions](#actions)
* [Lookup Object By ID](#lookup-object-by-id)
* [Make Raw Request](#make-raw-request)

## Description
Expand Down Expand Up @@ -39,6 +40,24 @@ Now you can create new credentials for the component on the platform:

## Actions

### Lookup Object By ID

Retrieves a single object using its ID.

#### Configuration Fields

- **Object Type** - (dropdown, required): The type of object to look up.

#### Input Metadata

- **ID Value** - (string, required): The ID of the object to look up.

#### Output Metadata

Returns an object with the result of the lookup.

**Known limitation**: Currently, the `Generate Stub Sample` button only allows generating generic metadata, without specific object type details.

### Make Raw Request

Executes custom request.
Expand Down
24 changes: 23 additions & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Podio component",
"description": "A smart connector for accessing Podio API",
"version": "1.0.0",
"version": "1.1.0-dev.1",
"authClientTypes": [
"oauth2"
],
Expand Down Expand Up @@ -33,6 +33,28 @@
}
},
"actions": {
"lookupObjectById": {
"main": "./src/actions/lookupObjectById.js",
"title": "Lookup Object By ID",
"help": {
"description": "Lookup Object By ID",
"link": "/components/podio/index.html#lookup-object-by-id"
},
"fields": {
"objectType": {
"label": "Object Type",
"viewClass": "SelectView",
"prompt": "Please select the type of object to lookup",
"required": true,
"order": 10,
"model": "getLookupByIdObjects"
}
},
"metadata": {
"in": "src/schemas/metadata/lookupObjectById/in.json",
"out": "src/schemas/metadata/lookupObjectById/out.json"
}
},
"makeRawRequest": {
"main": "./src/actions/rawRequest.js",
"title": "Make Raw Request",
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
"scripts": {
"audit": "better-npm-audit audit --level high --production",
"lint": "eslint --ext .ts --quiet --fix",
"pretest": "eslint --ext .ts --quiet --fix && find src spec spec-integration -name \\\"*.js\\\" -type f -delete && rm -f verifyCredentials.js",
"pretest": "eslint --ext .ts --quiet --fix && find src spec -name \\\"*.js\\\" -type f -delete && rm -f verifyCredentials.js",
"test": "mocha --require ts-node/register \"spec/**/*test.ts\"",
"integrationTest": "mocha --require ts-node/register --timeout 50000 \"spec-integration/**/*test.ts\" \"spec-integration/verifyCredentials.test.ts\"",
"dev:test": "find src spec spec-integration -name \\\"*.js\\\" -type f -delete && rm -f verifyCredentials.js && tsc && npm run test",
"dev:integrationTest": "env LOG_LEVEL=debug find src spec spec-integration -name \\\"*.js\\\" -type f -delete && rm -f verifyCredentials.js && tsc && npm run integrationTest",
"dev:test": "find src spec -name \\\"*.js\\\" -type f -delete && rm -f verifyCredentials.js && tsc && npm run test",
"posttest": "tsc"
},
"repository": {
Expand Down
16 changes: 0 additions & 16 deletions spec-integration/actions/rawRequest.test.ts

This file was deleted.

40 changes: 0 additions & 40 deletions spec-integration/common.ts

This file was deleted.

37 changes: 37 additions & 0 deletions spec/actions/lookupObjectById.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import sinon from 'sinon';
import chai, { expect } from 'chai';
import { getContext, StatusCodeError } from '../common';
import Client from '../../src/Client';
import { processAction } from '../../src/actions/lookupObjectById';
import task from '../resources/task.json';

const fakeResponse: any = {
data: task,
status: 200,
headers: {},
};

chai.use(require('chai-as-promised'));

describe('"Lookup Object by ID" action', async () => {
let execRequest;
describe('One contact found', async () => {
beforeEach(() => {
execRequest = sinon.stub(Client.prototype, 'apiRequest').callsFake(async () => fakeResponse);
});
afterEach(() => {
sinon.restore();
});
it('should successfully emit contact', async () => {
const cfg = {
objectType: 'task'
};
const msg = {
body: { idValue: '300975023' },
};
const { body } = await processAction.call(getContext(), msg, cfg);
expect(execRequest.callCount).to.equal(1);
expect(body).to.deep.equal(task);
});
});
});
163 changes: 163 additions & 0 deletions spec/resources/task.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
{
"comments": [],
"completed_by": null,
"completed_on": null,
"completed_via": null,
"created_by": {
"avatar": null,
"avatar_id": null,
"avatar_type": "file",
"image": null,
"last_seen_on": "2025-06-05 13:29:33",
"name": "Ps Team",
"id": 77032728,
"type": "user",
"url": "https://podio.com/users/77032728",
"user_id": 77032728
},
"created_on": "2025-05-28 11:17:52",
"created_via": {
"auth_client_id": 5553,
"display": false,
"id": 5553,
"name": "Welcome Tasks",
"url": null
},
"description": "Both apps are available here: https://podio.com/site/mobile",
"due_date": "2025-05-29",
"due_on": "2025-05-29 20:59:59",
"due_time": null,
"external_id": null,
"files": [],
"is_liked": false,
"labels": [
{
"color": "D1F3EC",
"label_id": 5673579,
"text": "Update ladel"
}
],
"like_count": 0,
"link": "https://podio.com/tasks/300975023",
"presence": {
"user_id": 77032728,
"signature": "0b879da261acb363d95398ddeacb46dd7d5e4e90",
"ref_type": "task",
"ref_id": 300975023
},
"private": true,
"push": {
"channel": "/task/300975023",
"timestamp": 1749130272,
"signature": "34226c49a50d4e3d66644a6d6a2382dcdcb0ddea",
"expires_in": 21600
},
"recurrence": null,
"ref": {
"created_by": {
"avatar": 128799219,
"avatar_id": 128799219,
"avatar_type": "file",
"image": {
"external_file_id": null,
"file_id": 128799219,
"hosted_by": "podio",
"hosted_by_humanized_name": "Podio",
"link": "https://files.podio.com/128799219",
"link_target": "_blank",
"thumbnail_link": "https://files.podio.com/128799219",
"uuid_link": "https://files.podio.com/768f766d-9ee6-4299-8cbb-b35f679d0a77"
},
"last_seen_on": "2015-01-08 12:23:54",
"name": "Igor Drobiazko",
"id": 2503534,
"type": "user",
"url": "https://podio.com/users/2503534",
"user_id": 2503534
},
"created_on": "2014-10-20 11:34:41",
"created_via": {
"auth_client_id": 1,
"display": false,
"id": 1,
"name": "Podio",
"url": null
},
"data": {
"item_accounting_info": {
"org_id": 786243,
"limit": 100,
"count": 26640,
"percent": 26640
},
"name": "Employee Network",
"org": {
"contract_status": "none",
"domains": [
"elastic.io"
],
"image": {
"external_file_id": null,
"file_id": 1177280231,
"hosted_by": "podio",
"hosted_by_humanized_name": "Podio",
"link": "https://files.podio.com/1177280231",
"link_target": "_blank",
"thumbnail_link": "https://files.podio.com/1177280231",
"uuid_link": "https://files.podio.com/0b14697b-413c-43c2-83f2-5203f54a8b20"
},
"logo": 1177280231,
"name": "elastic.io",
"org_id": 786243,
"premium": false,
"segment": null,
"segment_size": null,
"status": "active",
"tier": null,
"type": "free",
"url": "https://podio.com/elasticio",
"url_label": "elasticio"
},
"org_id": 786243,
"sharefile_vault_url": null,
"space_id": 2771109,
"type": "emp_network",
"url": "https://podio.com/elasticio/employeenetwork",
"url_label": "employeenetwork"
},
"id": 2771109,
"link": "https://podio.com/elasticio/employeenetwork",
"title": "Employee Network",
"type": "space",
"type_name": "workspace"
},
"reminder": null,
"responsible": {
"image": null,
"last_seen_on": "2025-06-05 13:29:33",
"link": "https://podio.com/users/77032728",
"org_id": null,
"profile_id": 271581035,
"type": "user",
"space_id": null,
"user_id": 77032728,
"avatar": null,
"name": "Ps Team"
},
"rights": [
"rate",
"update",
"subscribe",
"view",
"add_file",
"comment",
"delete"
],
"space_id": 2771109,
"started": false,
"status": "active",
"subscribed": true,
"subscribed_count": 1,
"task_id": 300975023,
"text": "Get tasks on the go. Download the iPhone or Android app now."
}
45 changes: 45 additions & 0 deletions src/actions/lookupObjectById.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as commons from '@elastic.io/component-commons-library';
import { messages } from 'elasticio-node';
import { lookupObjectByIdMapping } from '../utils';
import Client from '../Client';
import lookupByIdObjects from '../schemas/objectTypes/lookupObjectById.json';

let client: Client;

export async function processAction(msg: any, cfg: any) {
this.logger.info('"Lookup Object By ID" action started');

client ||= new Client(this, cfg);
client.setLogger(this.logger);

const { objectType } = cfg;

const { idValue } = msg.body;
if (!idValue) {
throw new Error('No "ID Value" provided!');
}

let url = lookupObjectByIdMapping[objectType]?.url;
if (!url) throw new Error(`Unsupported Object Type - ${objectType}`);

url = url.replace('{id}', idValue);

let result;
try {
const response = await client.apiRequest({ url, method: 'GET' });
result = response.data;
} catch (err) {
if (err.response) throw new Error(commons.getErrMsg(err.response));
throw err;
}

this.logger.info('"Lookup Object By ID" action is done, emitting...');
return messages.newMessageWithBody(result);
}

export const getLookupByIdObjects = async function getLookupByIdObjects() {
return lookupByIdObjects;
};

module.exports.process = processAction;
module.exports.getLookupByIdObjects = getLookupByIdObjects;
Loading