Hi @Eric_Koleda ! Thanks for your reply.
Yes, the signature process is where I got stuck. I did try to insert everything manually just to confirm I could connect to portal and I was able to get my proposal lists. However, in this manual process I had to generate the signature externally and paste it just to test it.
This is the code I used:
import * as coda from "@codahq/packs-sdk";
export const pack = coda.newPack();
// Set up the authentication parameters
pack.addNetworkDomain('api.portal.io');
pack.setUserAuthentication({
type: coda.AuthenticationType.Custom,
params: [
{
name: 'X-MSS-API-APPID',
description: 'Enter your API App ID',
},
{
name: 'X-MSS-CUSTOM-DATE',
description: 'Enter the custom date in GMT',
},
{
name: 'X-MSS-SIGNATURE',
description: 'Enter the API signature',
},
{
name: 'X-MSS-API-USERKEY',
description: 'Enter your API user key',
},
],
instructionsUrl: 'https://portalio.redoc.ly/',
});
// Define the schema for your sync table
const ProposalSchema = coda.makeObjectSchema({
properties: {
id: { type: coda.ValueType.String, fromKey: 'id' },
title: { type: coda.ValueType.String, fromKey: 'name' },
status: { type: coda.ValueType.String, fromKey: 'status' },
proposalTotal: { type: coda.ValueType.Number, fromKey: 'total.proposalTotal' },
createdDate: { type: coda.ValueType.String, fromKey: 'createdDate' },
lastModifiedDate: { type: coda.ValueType.String, fromKey: 'lastModifiedDate' },
customerName: { type: coda.ValueType.String, fromKey: 'customer.firstName' },
},
idProperty: 'id',
displayProperty: 'title',
});
// Add the sync table
pack.addSyncTable({
name: 'Proposals',
description: 'Sync table to fetch proposals from API',
identityName: 'Proposal',
schema: ProposalSchema,
formula: {
name: 'SyncProposals',
description: 'Fetches proposals from the API',
parameters: [
coda.makeParameter({
type: coda.ParameterType.String,
name: 'X_MSS_API_APPID',
description: 'Enter your API App ID',
}),
coda.makeParameter({
type: coda.ParameterType.String,
name: 'X_MSS_CUSTOM_DATE',
description: 'Enter the custom date in GMT',
}),
coda.makeParameter({
type: coda.ParameterType.String,
name: 'X_MSS_SIGNATURE',
description: 'Enter the API signature',
}),
coda.makeParameter({
type: coda.ParameterType.String,
name: 'X_MSS_API_USERKEY',
description: 'Enter your API user key',
}),
],
execute: async function (args, context) {
const [X_MSS_API_APPID, X_MSS_CUSTOM_DATE, X_MSS_SIGNATURE, X_MSS_API_USERKEY] = args;
const url = 'https://api.portal.io/public/proposals';
const response = await context.fetcher.fetch({
method: 'GET',
url: url,
headers: {
'X-MSS-API-APPID': X_MSS_API_APPID,
'X-MSS-CUSTOM-DATE': X_MSS_CUSTOM_DATE,
'X-MSS-SIGNATURE': X_MSS_SIGNATURE,
'X-MSS-API-USERKEY': X_MSS_API_USERKEY,
},
});
const proposals = response.body.proposals; // Access the proposals array within the response body
return proposals.map(proposal => ({
id: proposal.id.toString(),
title: proposal.name,
status: proposal.status,
proposalTotal: proposal.total.proposalTotal,
createdDate: proposal.createdDate,
lastModifiedDate: proposal.lastModifiedDate,
customerName: proposal.customer.firstName,
}));
},
},
});
Of course this code is not usable since I can’t rely on generating the signatuare manually and externally.
What would be the way that you suggested (even though as you said, it is not ideal) to pass the information as parameters?
Any help would be greatly appreciated!
Best,
MV