1+ import { createPiece , PieceAuth } from "@activepieces/pieces-framework" ;
2+ import { createCustomApiCallAction , HttpMethod } from '@activepieces/pieces-common' ;
3+ import { createItemAction } from './lib/actions/create-item' ;
4+ import { updateItemAction } from './lib/actions/update-item' ;
5+ import { createTaskAction } from './lib/actions/create-task' ;
6+ import { updateTaskAction } from './lib/actions/update-task' ;
7+ import { attachFileAction } from './lib/actions/attach-file' ;
8+ import { createCommentAction } from './lib/actions/create-comment' ;
9+ import { createStatusAction } from './lib/actions/create-status' ;
10+ import { findItemAction } from './lib/actions/find-item' ;
11+ import { findTaskAction } from './lib/actions/find-task' ;
12+ import { newItemTrigger } from './lib/triggers/new-item' ;
13+ import { newTaskTrigger } from './lib/triggers/new-task' ;
14+ import { newActivityTrigger } from './lib/triggers/new-activity' ;
15+ import { itemUpdatedTrigger } from './lib/triggers/item-updated' ;
16+ import { newOrganizationTrigger } from './lib/triggers/new-organization' ;
17+ import { newWorkspaceTrigger } from './lib/triggers/new-workspace' ;
18+ import { podioApiCall , validateAuthData } from './lib/common' ;
19+
20+ export const podioAuth = PieceAuth . OAuth2 ( {
21+ description : "Connect your Podio account to automate workspace management and item operations." ,
22+ authUrl : 'https://podio.com/oauth/authorize' ,
23+ tokenUrl : 'https://podio.com/oauth/token' ,
24+ required : true ,
25+ scope : [ 'global:read' , 'global:write' ] ,
26+ validate : async ( { auth } ) => {
27+ try {
28+ const validation = validateAuthData ( auth ) ;
29+ if ( ! validation . valid ) {
30+ return { valid : false , error : validation . error || 'Authentication validation failed' } ;
31+ }
32+
33+ const response = await podioApiCall ( {
34+ method : HttpMethod . GET ,
35+ accessToken : auth . access_token ,
36+ resourceUri : '/user/status' ,
37+ } ) ;
38+
39+ if ( response && typeof response === 'object' ) {
40+ return { valid : true } ;
41+ }
42+
43+ return { valid : false , error : 'Failed to validate connection with Podio API' } ;
44+ } catch ( error : any ) {
45+ if ( error . response ?. status === 401 ) {
46+ return { valid : false , error : 'Invalid or expired access token. Please reconnect your Podio account.' } ;
47+ }
48+
49+ if ( error . response ?. status === 403 ) {
50+ return { valid : false , error : 'Access denied. Please check your Podio permissions.' } ;
51+ }
52+
53+ return {
54+ valid : false ,
55+ error : `Connection validation failed: ${ error . message || 'Unknown error occurred' } `
56+ } ;
57+ }
58+ } ,
59+ } ) ;
60+
61+ export const podio = createPiece ( {
62+ displayName : "Podio" ,
63+ auth : podioAuth ,
64+ minimumSupportedRelease : '0.36.1' ,
65+ logoUrl : "https://cdn.activepieces.com/pieces/podio.png" ,
66+ authors : [ "sparkybug" , "onyedikachi-david" ] ,
67+ actions : [
68+ createItemAction ,
69+ updateItemAction ,
70+ createTaskAction ,
71+ updateTaskAction ,
72+ attachFileAction ,
73+ createCommentAction ,
74+ createStatusAction ,
75+ findItemAction ,
76+ findTaskAction ,
77+ createCustomApiCallAction ( {
78+ baseUrl : ( ) => 'https://api.podio.com' ,
79+ auth : podioAuth ,
80+ authMapping : async ( auth : any ) => ( {
81+ Authorization : `Bearer ${ auth . access_token } ` ,
82+ } ) ,
83+ } ) ,
84+ ] ,
85+ triggers : [
86+ newItemTrigger ,
87+ newTaskTrigger ,
88+ newActivityTrigger ,
89+ itemUpdatedTrigger ,
90+ newOrganizationTrigger ,
91+ newWorkspaceTrigger ,
92+ ] ,
93+ } ) ;
94+
0 commit comments