@coasy/piece-coasy 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +5 -1
- package/dist/packages/pieces/community/framework/packages/pieces/community/framework/README.md +11 -0
- package/dist/packages/shared/packages/shared/README.md +7 -0
- package/package.json +1 -1
- package/src/lib/actions/create-event-participant.ts +16 -25
- package/src/lib/actions/create-funnel-participant.ts +10 -17
- package/src/lib/actions/create-voucher.ts +5 -13
- package/src/lib/actions/enroll-user-course.ts +19 -29
- package/src/lib/actions/find-event.ts +13 -21
- package/src/lib/common/actions.ts +24 -0
- package/src/lib/common/triggers.ts +40 -25
- package/src/lib/triggers/cancelled-membership.ts +38 -21
- package/src/lib/triggers/cancelled-order-item.ts +48 -21
- package/src/lib/triggers/cancelled-order.ts +52 -21
- package/src/lib/triggers/cancelled-orderprocess.ts +40 -22
- package/src/lib/triggers/cancelled-subscription.ts +38 -21
- package/src/lib/triggers/get-events.ts +27 -20
- package/src/lib/triggers/new-event-participant.ts +43 -21
- package/src/lib/triggers/new-lead.ts +33 -22
- package/src/lib/triggers/new-membership.ts +38 -21
- package/src/lib/triggers/new-order-item.ts +46 -25
- package/src/lib/triggers/new-order.ts +48 -21
- package/src/lib/triggers/new-subscription.ts +38 -21
- package/src/lib/triggers/new-webinar-participant.ts +57 -30
- package/src/lib/triggers/webinar-participant-attend.ts +50 -38
- package/src/lib/triggers/webinar-participant-reminder.ts +48 -37
package/.eslintrc.json
CHANGED
package/dist/packages/pieces/community/framework/packages/pieces/community/framework/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# pieces-framework
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build pieces-framework` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test pieces-framework` to execute the unit tests via [Jest](https://jestjs.io).
|
package/package.json
CHANGED
|
@@ -1,34 +1,25 @@
|
|
|
1
|
-
import { createAction, Property } from
|
|
2
|
-
import { coasyAuth } from
|
|
3
|
-
import {
|
|
1
|
+
import { createAction, Property } from '@activepieces/pieces-framework';
|
|
2
|
+
import { coasyAuth } from '../..';
|
|
3
|
+
import { runCoasyAction } from '../common/actions';
|
|
4
|
+
|
|
5
|
+
const name = 'createEventParticipant';
|
|
4
6
|
|
|
5
7
|
export const createEventParticipant = createAction({
|
|
6
8
|
auth: coasyAuth,
|
|
7
|
-
name
|
|
8
|
-
displayName:
|
|
9
|
-
description:
|
|
9
|
+
name,
|
|
10
|
+
displayName: 'Create Event Participant',
|
|
11
|
+
description: 'Creates a new event participant',
|
|
10
12
|
props: {
|
|
11
13
|
eventId: Property.ShortText({
|
|
12
|
-
displayName:
|
|
13
|
-
description:
|
|
14
|
-
required: true
|
|
14
|
+
displayName: 'Event ID',
|
|
15
|
+
description: 'ID of event',
|
|
16
|
+
required: true,
|
|
15
17
|
}),
|
|
16
18
|
categoryId: Property.ShortText({
|
|
17
|
-
displayName:
|
|
18
|
-
description:
|
|
19
|
-
required: false
|
|
20
|
-
})
|
|
19
|
+
displayName: 'Category ID',
|
|
20
|
+
description: 'ID of category',
|
|
21
|
+
required: false,
|
|
22
|
+
}),
|
|
21
23
|
},
|
|
22
|
-
|
|
23
|
-
const { propsValue, auth } = configValue;
|
|
24
|
-
const client = new CoasyClient(
|
|
25
|
-
auth.baseUrl ?? "https://backend.api.prod.coasy.io",
|
|
26
|
-
auth.apiKey
|
|
27
|
-
);
|
|
28
|
-
const request = {
|
|
29
|
-
eventId: propsValue.eventId,
|
|
30
|
-
categoryId: propsValue.categoryId
|
|
31
|
-
};
|
|
32
|
-
return client.action("createEventParticipant", request);
|
|
33
|
-
}
|
|
24
|
+
run: (configValue) => runCoasyAction(configValue, name),
|
|
34
25
|
});
|
|
@@ -1,42 +1,35 @@
|
|
|
1
1
|
import { createAction, Property } from '@activepieces/pieces-framework';
|
|
2
2
|
import { coasyAuth } from '../../index';
|
|
3
|
-
import {
|
|
3
|
+
import { runCoasyAction } from '../common/actions';
|
|
4
|
+
|
|
5
|
+
const name = 'createFunnelParticipant';
|
|
4
6
|
|
|
5
7
|
export const createFunnelParticipant = createAction({
|
|
6
8
|
auth: coasyAuth,
|
|
7
|
-
name
|
|
9
|
+
name,
|
|
8
10
|
displayName: 'Create Funnel Participant',
|
|
9
11
|
description: 'Create a new funnel participant',
|
|
10
12
|
props: {
|
|
11
13
|
funnelId: Property.ShortText({
|
|
12
14
|
displayName: 'Funnel ID',
|
|
13
15
|
description: 'ID of funnel',
|
|
14
|
-
required: true
|
|
16
|
+
required: true,
|
|
15
17
|
}),
|
|
16
18
|
firstName: Property.ShortText({
|
|
17
19
|
displayName: 'First name',
|
|
18
20
|
description: 'first name of participant',
|
|
19
|
-
required: true
|
|
21
|
+
required: true,
|
|
20
22
|
}),
|
|
21
23
|
lastName: Property.ShortText({
|
|
22
24
|
displayName: 'Last name',
|
|
23
25
|
description: 'last name of participant',
|
|
24
|
-
required: false
|
|
26
|
+
required: false,
|
|
25
27
|
}),
|
|
26
28
|
email: Property.ShortText({
|
|
27
29
|
displayName: 'Email',
|
|
28
30
|
description: 'email address of partipant',
|
|
29
|
-
required: true
|
|
30
|
-
})
|
|
31
|
+
required: true,
|
|
32
|
+
}),
|
|
31
33
|
},
|
|
32
|
-
|
|
33
|
-
const { propsValue, auth } = configValue;
|
|
34
|
-
const client = new CoasyClient(auth.baseUrl ?? 'https://backend.api.prod.coasy.io', auth.apiKey);
|
|
35
|
-
const request = {
|
|
36
|
-
email: propsValue.email,
|
|
37
|
-
firstName: propsValue.firstName,
|
|
38
|
-
funnelId: propsValue.funnelId
|
|
39
|
-
};
|
|
40
|
-
return client.action('createFunnelParticipant', request);
|
|
41
|
-
}
|
|
34
|
+
run: (configValue) => runCoasyAction(configValue, name),
|
|
42
35
|
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { createAction, Property } from '@activepieces/pieces-framework';
|
|
2
2
|
import { coasyAuth } from '../..';
|
|
3
|
-
import {
|
|
3
|
+
import { runCoasyAction } from '../common/actions';
|
|
4
|
+
|
|
5
|
+
const name = 'createVoucher';
|
|
4
6
|
|
|
5
7
|
export const createVoucher = createAction({
|
|
6
8
|
auth: coasyAuth,
|
|
7
|
-
name
|
|
9
|
+
name,
|
|
8
10
|
displayName: 'Create Voucher',
|
|
9
11
|
description: 'Creates a new voucher',
|
|
10
12
|
props: {
|
|
@@ -14,15 +16,5 @@ export const createVoucher = createAction({
|
|
|
14
16
|
required: true,
|
|
15
17
|
}),
|
|
16
18
|
},
|
|
17
|
-
|
|
18
|
-
const { propsValue, auth } = configValue;
|
|
19
|
-
const client = new CoasyClient(
|
|
20
|
-
auth.baseUrl ?? 'https://backend.api.prod.coasy.io',
|
|
21
|
-
auth.apiKey
|
|
22
|
-
);
|
|
23
|
-
const request = {
|
|
24
|
-
offerId: propsValue.offerId,
|
|
25
|
-
};
|
|
26
|
-
return client.action('createVoucher', request);
|
|
27
|
-
},
|
|
19
|
+
run: (configValue) => runCoasyAction(configValue, name),
|
|
28
20
|
});
|
|
@@ -1,40 +1,30 @@
|
|
|
1
|
-
import { createAction, Property } from
|
|
2
|
-
import { coasyAuth } from
|
|
3
|
-
import {
|
|
1
|
+
import { createAction, Property } from '@activepieces/pieces-framework';
|
|
2
|
+
import { coasyAuth } from '../..';
|
|
3
|
+
import { runCoasyAction } from '../common/actions';
|
|
4
|
+
|
|
5
|
+
const name = 'enrollUserCourse';
|
|
4
6
|
|
|
5
7
|
export const enrollUserCourse = createAction({
|
|
6
8
|
auth: coasyAuth,
|
|
7
|
-
name
|
|
8
|
-
displayName:
|
|
9
|
-
description:
|
|
9
|
+
name,
|
|
10
|
+
displayName: 'Enroll User Course',
|
|
11
|
+
description: 'Enrolls user course',
|
|
10
12
|
props: {
|
|
11
13
|
userId: Property.ShortText({
|
|
12
|
-
displayName:
|
|
13
|
-
description:
|
|
14
|
-
required: true
|
|
14
|
+
displayName: 'User ID',
|
|
15
|
+
description: 'ID of User',
|
|
16
|
+
required: true,
|
|
15
17
|
}),
|
|
16
18
|
courseId: Property.ShortText({
|
|
17
|
-
displayName:
|
|
18
|
-
description:
|
|
19
|
-
required: true
|
|
19
|
+
displayName: 'Course ID',
|
|
20
|
+
description: 'ID of Course',
|
|
21
|
+
required: true,
|
|
20
22
|
}),
|
|
21
23
|
directGrant: Property.Checkbox({
|
|
22
|
-
displayName:
|
|
23
|
-
description:
|
|
24
|
-
required: true
|
|
25
|
-
})
|
|
24
|
+
displayName: 'Direct Grant',
|
|
25
|
+
description: 'Give direct grant',
|
|
26
|
+
required: true,
|
|
27
|
+
}),
|
|
26
28
|
},
|
|
27
|
-
|
|
28
|
-
const { propsValue, auth } = configValue;
|
|
29
|
-
const client = new CoasyClient(
|
|
30
|
-
auth.baseUrl ?? "https://backend.api.prod.coasy.io",
|
|
31
|
-
auth.apiKey
|
|
32
|
-
);
|
|
33
|
-
const request = {
|
|
34
|
-
userId: propsValue.userId,
|
|
35
|
-
courseId: propsValue.courseId,
|
|
36
|
-
directGrant: propsValue.directGrant
|
|
37
|
-
};
|
|
38
|
-
return client.action("enrollUserCourse", request);
|
|
39
|
-
}
|
|
29
|
+
run: configValue => runCoasyAction(configValue, name),
|
|
40
30
|
});
|
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
import { createAction, Property } from
|
|
2
|
-
import { coasyAuth } from
|
|
3
|
-
import {
|
|
1
|
+
import { createAction, Property } from '@activepieces/pieces-framework';
|
|
2
|
+
import { coasyAuth } from '../..';
|
|
3
|
+
import { runCoasyAction } from '../common/actions';
|
|
4
|
+
|
|
5
|
+
const name = 'findEvent';
|
|
4
6
|
|
|
5
7
|
export const findEvent = createAction({
|
|
6
8
|
auth: coasyAuth,
|
|
7
|
-
name
|
|
8
|
-
displayName:
|
|
9
|
-
description:
|
|
9
|
+
name,
|
|
10
|
+
displayName: 'Find Event',
|
|
11
|
+
description: 'Finds Event',
|
|
10
12
|
props: {
|
|
11
13
|
title: Property.ShortText({
|
|
12
|
-
displayName:
|
|
13
|
-
description:
|
|
14
|
-
required: false
|
|
15
|
-
})
|
|
14
|
+
displayName: 'Title',
|
|
15
|
+
description: 'Title Name',
|
|
16
|
+
required: false,
|
|
17
|
+
}),
|
|
16
18
|
},
|
|
17
|
-
|
|
18
|
-
const { propsValue, auth } = configValue;
|
|
19
|
-
const client = new CoasyClient(
|
|
20
|
-
auth.baseUrl ?? "https://backend.api.prod.coasy.io",
|
|
21
|
-
auth.apiKey
|
|
22
|
-
);
|
|
23
|
-
const request = {
|
|
24
|
-
title: propsValue.title
|
|
25
|
-
};
|
|
26
|
-
return client.action("findEvent", request);
|
|
27
|
-
}
|
|
19
|
+
run: configValue => runCoasyAction(configValue, name),
|
|
28
20
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActionContext,
|
|
3
|
+
InputPropertyMap,
|
|
4
|
+
} from '@activepieces/pieces-framework';
|
|
5
|
+
import { coasyAuth } from '../..';
|
|
6
|
+
import { CoasyClient } from './coasyClient';
|
|
7
|
+
|
|
8
|
+
export const runCoasyAction = async <T extends InputPropertyMap>(
|
|
9
|
+
configValue: ActionContext<typeof coasyAuth, T>,
|
|
10
|
+
action: string
|
|
11
|
+
) => {
|
|
12
|
+
const { propsValue, auth: authPayload } = configValue;
|
|
13
|
+
const client = new CoasyClient(
|
|
14
|
+
authPayload.baseUrl ?? 'https://backend.api.prod.coasy.io',
|
|
15
|
+
authPayload.apiKey
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const { ...restPropsValue } = propsValue;
|
|
19
|
+
|
|
20
|
+
delete restPropsValue['auth'];
|
|
21
|
+
|
|
22
|
+
const request = { ...restPropsValue };
|
|
23
|
+
return client.action(action, request);
|
|
24
|
+
};
|
|
@@ -1,58 +1,73 @@
|
|
|
1
|
-
|
|
2
1
|
import { CoasyClient } from './coasyClient';
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
SecretTextProperty,
|
|
5
|
+
ShortTextProperty,
|
|
6
|
+
StaticPropsValue,
|
|
7
|
+
Store,
|
|
8
|
+
} from '@activepieces/pieces-framework';
|
|
5
9
|
|
|
6
10
|
export interface CreateTriggerRequest {
|
|
7
11
|
triggerName: string;
|
|
8
12
|
webhookUrl: string;
|
|
9
|
-
auth:
|
|
10
|
-
baseUrl: ShortTextProperty<false
|
|
11
|
-
apiKey: SecretTextProperty<true
|
|
12
|
-
}
|
|
13
|
+
auth: StaticPropsValue<{
|
|
14
|
+
baseUrl: ShortTextProperty<false>;
|
|
15
|
+
apiKey: SecretTextProperty<true>;
|
|
16
|
+
}>;
|
|
13
17
|
filter: any;
|
|
14
18
|
store: Store;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export interface DestroyTriggerRequest {
|
|
18
22
|
triggerName: string;
|
|
19
|
-
auth:
|
|
20
|
-
baseUrl: ShortTextProperty<false
|
|
21
|
-
apiKey: SecretTextProperty<true
|
|
22
|
-
}
|
|
23
|
+
auth: StaticPropsValue<{
|
|
24
|
+
baseUrl: ShortTextProperty<false>;
|
|
25
|
+
apiKey: SecretTextProperty<true>;
|
|
26
|
+
}>;
|
|
23
27
|
store: Store;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
export interface TestTriggerRequest {
|
|
27
31
|
triggerName: string;
|
|
28
|
-
auth:
|
|
29
|
-
baseUrl: ShortTextProperty<false
|
|
30
|
-
apiKey: SecretTextProperty<true
|
|
31
|
-
}
|
|
32
|
+
auth: StaticPropsValue<{
|
|
33
|
+
baseUrl: ShortTextProperty<false>;
|
|
34
|
+
apiKey: SecretTextProperty<true>;
|
|
35
|
+
}>;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
export const createCoasyTrigger = async (request: CreateTriggerRequest) => {
|
|
35
|
-
const { triggerName, webhookUrl, filter, auth, store} = request;
|
|
36
|
-
const client = new CoasyClient(
|
|
39
|
+
const { triggerName, webhookUrl, filter, auth, store } = request;
|
|
40
|
+
const client = new CoasyClient(
|
|
41
|
+
auth.baseUrl ?? 'https://backend.api.prod.coasy.io',
|
|
42
|
+
auth.apiKey
|
|
43
|
+
);
|
|
37
44
|
const response = await client.createTrigger(triggerName, webhookUrl, filter);
|
|
38
45
|
if (!response.id) throw new Error(`Failed to create Trigger!`);
|
|
39
46
|
await store.put<string>(`${triggerName}__WEBHOOK_ID`, response.id);
|
|
40
47
|
};
|
|
41
48
|
|
|
42
|
-
export const destroyCoasyTrigger = async (request: DestroyTriggerRequest) =>
|
|
43
|
-
const { triggerName, auth, store} = request;
|
|
49
|
+
export const destroyCoasyTrigger = async (request: DestroyTriggerRequest) => {
|
|
50
|
+
const { triggerName, auth, store } = request;
|
|
44
51
|
const webhookId = await store.get<string>(`${triggerName}__WEBHOOK_ID`);
|
|
45
52
|
if (!webhookId) throw new Error(`Webhook Id not found!`);
|
|
46
53
|
|
|
47
|
-
const client = new CoasyClient(
|
|
54
|
+
const client = new CoasyClient(
|
|
55
|
+
auth.baseUrl ?? 'https://backend.api.prod.coasy.io',
|
|
56
|
+
auth.apiKey
|
|
57
|
+
);
|
|
48
58
|
await client.destroyTrigger(webhookId);
|
|
49
|
-
}
|
|
59
|
+
};
|
|
50
60
|
|
|
51
|
-
export const testCoasyTrigger = async (
|
|
52
|
-
|
|
61
|
+
export const testCoasyTrigger = async (
|
|
62
|
+
request: TestTriggerRequest
|
|
63
|
+
): Promise<any[]> => {
|
|
64
|
+
const { triggerName, auth } = request;
|
|
53
65
|
|
|
54
|
-
const client = new CoasyClient(
|
|
66
|
+
const client = new CoasyClient(
|
|
67
|
+
auth.baseUrl ?? 'https://backend.api.prod.coasy.io',
|
|
68
|
+
auth.apiKey
|
|
69
|
+
);
|
|
55
70
|
const response = await client.listTriggerEvents(triggerName);
|
|
56
71
|
|
|
57
|
-
return [{ test: true}];
|
|
58
|
-
}
|
|
72
|
+
return [{ test: true, response }];
|
|
73
|
+
};
|
|
@@ -1,34 +1,51 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createTrigger,
|
|
3
|
+
Property,
|
|
4
|
+
TriggerStrategy,
|
|
5
|
+
} from '@activepieces/pieces-framework';
|
|
2
6
|
import { coasyAuth } from '../..';
|
|
3
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
createCoasyTrigger,
|
|
9
|
+
destroyCoasyTrigger,
|
|
10
|
+
testCoasyTrigger,
|
|
11
|
+
} from '../common/triggers';
|
|
4
12
|
|
|
5
|
-
const triggerName =
|
|
13
|
+
const triggerName = 'CANCELLED_MEMBERSHIP';
|
|
6
14
|
|
|
7
15
|
export const cancelledMembership = createTrigger({
|
|
8
16
|
auth: coasyAuth,
|
|
9
17
|
name: 'cancelledMembership',
|
|
10
18
|
displayName: 'Cancelled Membership',
|
|
11
19
|
description: 'Triggers when a customer requests a membership cancellation.',
|
|
12
|
-
props: {
|
|
20
|
+
props: {
|
|
21
|
+
membershipTypeIds: Property.Array({
|
|
22
|
+
displayName: 'Membership Type IDs',
|
|
23
|
+
description: 'IDs of membership types to react to',
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
13
27
|
sampleData: {},
|
|
14
28
|
type: TriggerStrategy.WEBHOOK,
|
|
15
|
-
onEnable: (context) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
onEnable: (context) =>
|
|
30
|
+
createCoasyTrigger({
|
|
31
|
+
triggerName,
|
|
32
|
+
webhookUrl: context.webhookUrl,
|
|
33
|
+
auth: context.auth,
|
|
34
|
+
filter: context.propsValue,
|
|
35
|
+
store: context.store,
|
|
36
|
+
}),
|
|
37
|
+
onDisable: (context) =>
|
|
38
|
+
destroyCoasyTrigger({
|
|
39
|
+
triggerName,
|
|
40
|
+
auth: context.auth,
|
|
41
|
+
store: context.store,
|
|
42
|
+
}),
|
|
43
|
+
test: (context) =>
|
|
44
|
+
testCoasyTrigger({
|
|
45
|
+
triggerName,
|
|
46
|
+
auth: context.auth,
|
|
47
|
+
}),
|
|
31
48
|
async run(context) {
|
|
32
49
|
return [context.payload.body];
|
|
33
|
-
}
|
|
50
|
+
},
|
|
34
51
|
});
|
|
@@ -1,34 +1,61 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createTrigger,
|
|
3
|
+
Property,
|
|
4
|
+
TriggerStrategy,
|
|
5
|
+
} from '@activepieces/pieces-framework';
|
|
2
6
|
import { coasyAuth } from '../..';
|
|
3
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
createCoasyTrigger,
|
|
9
|
+
destroyCoasyTrigger,
|
|
10
|
+
testCoasyTrigger,
|
|
11
|
+
} from '../common/triggers';
|
|
4
12
|
|
|
5
|
-
const triggerName =
|
|
13
|
+
const triggerName = 'CANCELLED_ORDER_ITEM';
|
|
6
14
|
|
|
7
15
|
export const cancelledOrderItem = createTrigger({
|
|
8
16
|
auth: coasyAuth,
|
|
9
17
|
name: 'cancelledOrderItem',
|
|
10
18
|
displayName: 'Cancelled Order Item',
|
|
11
19
|
description: 'Triggers when an order item is cancelled.',
|
|
12
|
-
props: {
|
|
20
|
+
props: {
|
|
21
|
+
mainOfferIds: Property.Array({
|
|
22
|
+
displayName: 'Main Offer IDs',
|
|
23
|
+
description: 'IDs of main offers to react to',
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
26
|
+
selectedPaymentPlans: Property.Array({
|
|
27
|
+
displayName: 'Selected Payment Plans',
|
|
28
|
+
description: 'Payment plans to filter by',
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
31
|
+
selectedShippingOptions: Property.Array({
|
|
32
|
+
displayName: 'Selected Shipping Options',
|
|
33
|
+
description: 'Shipping options to filter by',
|
|
34
|
+
required: false,
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
13
37
|
sampleData: {},
|
|
14
38
|
type: TriggerStrategy.WEBHOOK,
|
|
15
|
-
onEnable: (context) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
onEnable: (context) =>
|
|
40
|
+
createCoasyTrigger({
|
|
41
|
+
triggerName,
|
|
42
|
+
webhookUrl: context.webhookUrl,
|
|
43
|
+
auth: context.auth,
|
|
44
|
+
filter: context.propsValue,
|
|
45
|
+
store: context.store,
|
|
46
|
+
}),
|
|
47
|
+
onDisable: (context) =>
|
|
48
|
+
destroyCoasyTrigger({
|
|
49
|
+
triggerName,
|
|
50
|
+
auth: context.auth,
|
|
51
|
+
store: context.store,
|
|
52
|
+
}),
|
|
53
|
+
test: (context) =>
|
|
54
|
+
testCoasyTrigger({
|
|
55
|
+
triggerName,
|
|
56
|
+
auth: context.auth,
|
|
57
|
+
}),
|
|
31
58
|
async run(context) {
|
|
32
59
|
return [context.payload.body];
|
|
33
|
-
}
|
|
60
|
+
},
|
|
34
61
|
});
|
|
@@ -1,34 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
<<<<<<< Updated upstream
|
|
2
|
+
import {
|
|
3
|
+
createTrigger,
|
|
4
|
+
Property,
|
|
5
|
+
TriggerStrategy,
|
|
6
|
+
} from '@activepieces/pieces-framework';
|
|
7
|
+
=======
|
|
8
|
+
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
|
|
9
|
+
>>>>>>> Stashed changes
|
|
2
10
|
import { coasyAuth } from '../..';
|
|
3
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
createCoasyTrigger,
|
|
13
|
+
destroyCoasyTrigger,
|
|
14
|
+
testCoasyTrigger,
|
|
15
|
+
} from '../common/triggers';
|
|
4
16
|
|
|
5
|
-
const triggerName =
|
|
17
|
+
const triggerName = 'CANCELLED_ORDER';
|
|
6
18
|
|
|
7
19
|
export const cancelledOrder = createTrigger({
|
|
8
20
|
auth: coasyAuth,
|
|
9
21
|
name: 'cancelledOrder',
|
|
10
22
|
displayName: 'Cancelled Order',
|
|
11
23
|
description: 'Triggers when an order is cancelled.',
|
|
12
|
-
props: {
|
|
24
|
+
props: {
|
|
25
|
+
mainOfferIds: Property.Array({
|
|
26
|
+
displayName: 'Main Offer IDs',
|
|
27
|
+
description: 'IDs of main offers to react to',
|
|
28
|
+
required: false,
|
|
29
|
+
}),
|
|
30
|
+
selectedPaymentPlans: Property.Array({
|
|
31
|
+
displayName: 'Selected Payment Plans',
|
|
32
|
+
description: 'Payment plans to filter by',
|
|
33
|
+
required: false,
|
|
34
|
+
}),
|
|
35
|
+
selectedShippingOptions: Property.Array({
|
|
36
|
+
displayName: 'Selected Shipping Options',
|
|
37
|
+
description: 'Shipping options to filter by',
|
|
38
|
+
required: false,
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
13
41
|
sampleData: {},
|
|
14
42
|
type: TriggerStrategy.WEBHOOK,
|
|
15
|
-
onEnable: (context) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
43
|
+
onEnable: (context) =>
|
|
44
|
+
createCoasyTrigger({
|
|
45
|
+
triggerName,
|
|
46
|
+
webhookUrl: context.webhookUrl,
|
|
47
|
+
auth: context.auth,
|
|
48
|
+
filter: context.propsValue,
|
|
49
|
+
store: context.store,
|
|
50
|
+
}),
|
|
51
|
+
onDisable: (context) =>
|
|
52
|
+
destroyCoasyTrigger({
|
|
53
|
+
triggerName,
|
|
54
|
+
auth: context.auth,
|
|
55
|
+
store: context.store,
|
|
56
|
+
}),
|
|
57
|
+
test: (context) =>
|
|
58
|
+
testCoasyTrigger({
|
|
59
|
+
triggerName,
|
|
60
|
+
auth: context.auth,
|
|
61
|
+
}),
|
|
31
62
|
async run(context) {
|
|
32
63
|
return [context.payload.body];
|
|
33
|
-
}
|
|
64
|
+
},
|
|
34
65
|
});
|