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
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-contiguity",
"version": "0.1.12"
"version": "0.1.13"
}
34 changes: 17 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ import { sendText } from './lib/actions/send/text';
import { send_iMessage } from './lib/actions/send/imessage';

export const contiguityAuth = PieceAuth.SecretText({
displayName: 'API Key',
required: true,
description: 'Authenticate with the Contiguity API using a revocable key. Create one at console.contiguity.com/dashboard/tokens',
displayName: 'API Key',
required: true,
description: 'Authenticate with the Contiguity API using a revocable key. Create one at console.contiguity.com/dashboard/tokens',
});

export const contiguity = createPiece({
displayName: 'Contiguity',
description: 'Communications for what you\'re building',
auth: contiguityAuth,
minimumSupportedRelease: '0.30.0',
logoUrl: 'https://cdn.activepieces.com/pieces/contiguity.png',
authors: ["Owlcept", "Ozak93", "kishanprmr", "MoShizzle", "abuaboud", "Contiguity"],
categories: [PieceCategory.MARKETING],
actions: [
sendText,
send_iMessage,
createCustomApiCallAction({
displayName: 'Contiguity',
description: 'Communications for what you\'re building',
auth: contiguityAuth,
minimumSupportedRelease: '0.30.0',
logoUrl: 'https://cdn.activepieces.com/pieces/contiguity.png',
authors: ["Owlcept","Ozak93","kishanprmr","MoShizzle","abuaboud","Contiguity"],
categories: [PieceCategory.MARKETING],
actions: [
sendText,
send_iMessage,
createCustomApiCallAction({
baseUrl: () => 'https://api.contiguity.com',
auth: contiguityAuth,
authMapping: async (auth) => ({
authorization: `Bearer ${auth}`,
}),
}),
],
triggers: [],
}),
],
triggers: [],
});
58 changes: 39 additions & 19 deletions src/lib/actions/send/imessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
} from '@activepieces/pieces-common';
import { contiguityAuth } from '../../..';
import {
InputPropertyMap,
Property,
createAction,
} from '@activepieces/pieces-framework';
Expand Down Expand Up @@ -31,25 +32,45 @@ export const send_iMessage = createAction({
description: 'iMessage content',
required: true,
}),
fallback: Property.Object({
fallback: Property.Checkbox({
displayName: 'SMS/RCS Fallback',
description: 'Fallback to SMS/RCS when iMessage fails or unsupported',
required: false,
properties: {
when: Property.MultiSelectDropdown({
displayName: 'When to Fallback',
description: 'Conditions that trigger SMS/RCS fallback',
required: true,
options: [
{ label: 'iMessage Unsupported', value: 'imessage_unsupported' },
{ label: 'iMessage Fails', value: 'imessage_fails' },
],
}),
from: Property.ShortText({
displayName: 'Fallback From Number',
description: 'SMS/RCS number for fallback',
required: false,
}),
defaultValue: false,
}),
fallback_when: Property.DynamicProperties({
displayName: "When to fallback",
description: 'Conditions that trigger SMS/RCS fallback',
required: true,
refreshers: ['fallback'],
props: async (propsValue): Promise<InputPropertyMap> => {
const fallback = propsValue['fallback'] as unknown as boolean;

if (!fallback){
return{}
}

if (fallback){
return{
when: Property.StaticMultiSelectDropdown({
displayName: "When to fallback",
description: "Conditions that trigger SMS/RCS fallback",
required: true,
options: {
options:[
{ label: 'iMessage Unsupported', value: 'imessage_unsupported' },
{ label: 'iMessage Fails', value: 'imessage_fails' },
]
}
}),
from: Property.ShortText({
displayName: 'Fallback From Number',
description: 'SMS/RCS number for fallback',
required: false,
}),
};
}
return{};
},
}),
attachments: Property.Array({
Expand Down Expand Up @@ -83,14 +104,13 @@ export const send_iMessage = createAction({
).max(10, 'Maximum 10 attachments').optional(),
});

const { to, from, message, fallback, attachments } = context.propsValue;
const { to, from, message, attachments } = context.propsValue;

const body: any = { to, message };

if (from) body.from = from;
if (fallback) body.fallback = fallback;
if (attachments?.length) {
body.attachments = attachments.map(attachment => attachment.url);
body.attachments = attachments.map(attachment => (attachment as {url: string}).url);
}

return await _fetch({
Expand Down
3 changes: 1 addition & 2 deletions src/lib/actions/send/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ export const sendText = createAction({
const { to, from, message, attachments } = context.propsValue;

const body: any = { to, message };

if (from) body.from = from;
if (attachments?.length) {
body.attachments = attachments.map(attachment => attachment.url);
body.attachments = attachments.map(attachment => (attachment as {url: string}).url);
}

return await _fetch({
Expand Down