@coasy/piece-coasy 0.1.2-dev.1 → 0.1.3
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/package.json +1 -1
- package/src/lib/actions/create-event-participant.ts +17 -26
- package/src/lib/actions/create-funnel-participant.ts +10 -17
- package/src/lib/actions/create-voucher.ts +40 -22
- 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/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,
|
|
17
|
+
}),
|
|
18
|
+
eventCategoryId: Property.ShortText({
|
|
19
|
+
displayName: 'Category ID',
|
|
20
|
+
description: 'ID of category',
|
|
21
|
+
required: true,
|
|
15
22
|
}),
|
|
16
|
-
categoryId: Property.ShortText({
|
|
17
|
-
displayName: "Category ID",
|
|
18
|
-
description: "ID of category",
|
|
19
|
-
required: false
|
|
20
|
-
})
|
|
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,28 +1,46 @@
|
|
|
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 = 'createVoucher';
|
|
4
6
|
|
|
5
7
|
export const createVoucher = createAction({
|
|
6
8
|
auth: coasyAuth,
|
|
7
|
-
name
|
|
8
|
-
displayName:
|
|
9
|
-
description:
|
|
9
|
+
name,
|
|
10
|
+
displayName: 'Create Voucher',
|
|
11
|
+
description: 'Creates a new voucher',
|
|
10
12
|
props: {
|
|
11
|
-
|
|
12
|
-
displayName:
|
|
13
|
-
description:
|
|
14
|
-
required:
|
|
15
|
-
})
|
|
13
|
+
offerIds: Property.Array({
|
|
14
|
+
displayName: 'Offer ID',
|
|
15
|
+
description: 'ID of offer',
|
|
16
|
+
required: false,
|
|
17
|
+
}),
|
|
18
|
+
countLeft: Property.Number({
|
|
19
|
+
displayName: 'Quantity',
|
|
20
|
+
description: 'Count of vouchers',
|
|
21
|
+
required: false,
|
|
22
|
+
}),
|
|
23
|
+
recurringPeriod: Property.StaticDropdown({
|
|
24
|
+
displayName: 'Recurring period',
|
|
25
|
+
description: 'How the voucher will recurre',
|
|
26
|
+
required: false,
|
|
27
|
+
options: {
|
|
28
|
+
options: [
|
|
29
|
+
{
|
|
30
|
+
label: 'Monthly',
|
|
31
|
+
value: 'MONTHLY',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: 'Quarterly',
|
|
35
|
+
value: 'QUARTERLY',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: 'Yearly',
|
|
39
|
+
value: 'YEARLY',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
16
44
|
},
|
|
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
|
-
}
|
|
45
|
+
run: (configValue) => runCoasyAction(configValue, name),
|
|
28
46
|
});
|
|
@@ -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:
|
|
25
|
-
})
|
|
24
|
+
displayName: 'Direct Grant',
|
|
25
|
+
description: 'Give direct grant',
|
|
26
|
+
required: false,
|
|
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
|
+
};
|