@pipedream/evenium 0.6.0 → 0.7.0

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.
@@ -0,0 +1,92 @@
1
+ import {
2
+ PARTICIPANT_GENDER_OPTIONS,
3
+ PARTICIPANT_STATUS_OPTIONS,
4
+ } from "../../common/constants.mjs";
5
+ import app from "../../evenium.app.mjs";
6
+
7
+ export default {
8
+ type: "action",
9
+ key: "evenium-add-participants",
10
+ version: "0.0.1",
11
+ name: "Add Participants",
12
+ description: "Adds participants (guests) to an event. [See the documentation](https://static.evenium.com/api-docs/organizer/index-json.html#5.3)",
13
+ annotations: {
14
+ destructiveHint: false,
15
+ openWorldHint: true,
16
+ readOnlyHint: false,
17
+ },
18
+ props: {
19
+ app,
20
+ eventId: {
21
+ propDefinition: [
22
+ app,
23
+ "eventId",
24
+ ],
25
+ },
26
+ firstName: {
27
+ type: "string",
28
+ label: "First Name",
29
+ description: "The first name of the participant",
30
+ },
31
+ lastName: {
32
+ type: "string",
33
+ label: "Last Name",
34
+ description: "The last name of the participant",
35
+ },
36
+ email: {
37
+ type: "string",
38
+ label: "Email",
39
+ description: "The email address of the participant",
40
+ },
41
+ company: {
42
+ type: "string",
43
+ label: "Company",
44
+ description: "The company name of the participant",
45
+ optional: true,
46
+ },
47
+ gender: {
48
+ type: "string",
49
+ label: "Gender",
50
+ description: "The gender of the participant",
51
+ optional: true,
52
+ options: PARTICIPANT_GENDER_OPTIONS,
53
+ },
54
+ status: {
55
+ type: "string",
56
+ label: "Status",
57
+ description: "The registration status of the participant",
58
+ optional: true,
59
+ options: PARTICIPANT_STATUS_OPTIONS,
60
+ },
61
+ },
62
+ async run({ $ }) {
63
+ const guestData = {
64
+ firstName: this.firstName,
65
+ lastName: this.lastName,
66
+ email: this.email,
67
+ };
68
+
69
+ if (this.company) {
70
+ guestData.company = this.company;
71
+ }
72
+
73
+ if (this.gender) {
74
+ guestData.gender = this.gender;
75
+ }
76
+
77
+ if (this.status) {
78
+ guestData.status = this.status;
79
+ }
80
+
81
+ const response = await this.app.createGuest({
82
+ $,
83
+ eventId: this.eventId,
84
+ data: guestData,
85
+ });
86
+
87
+ $.export("$summary", `Successfully added participant "**${this.firstName} ${this.lastName}**" with \`guestId\`: ${response.guestId}`);
88
+
89
+ return response;
90
+ },
91
+ };
92
+
@@ -0,0 +1,84 @@
1
+ import app from "../../evenium.app.mjs";
2
+
3
+ export default {
4
+ type: "action",
5
+ key: "evenium-create-event",
6
+ version: "0.0.1",
7
+ name: "Create Event",
8
+ description: "Creates a new event. [See the documentation](https://static.evenium.com/api-docs/organizer/index-json.html#_create_events)",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: false,
13
+ },
14
+ props: {
15
+ app,
16
+ title: {
17
+ type: "string",
18
+ label: "Title",
19
+ description: "The title of the event",
20
+ },
21
+ startDate: {
22
+ type: "string",
23
+ label: "Start Date",
24
+ description: "The start date of the event in RFC 3339 format (e.g., 2010-07-10T07:00:00.000Z)",
25
+ },
26
+ endDate: {
27
+ type: "string",
28
+ label: "End Date",
29
+ description: "The end date of the event in RFC 3339 format (e.g., 2010-07-12T17:00:00.000Z)",
30
+ },
31
+ description: {
32
+ type: "string",
33
+ label: "Description",
34
+ description: "The description of the event",
35
+ optional: true,
36
+ },
37
+ addressName: {
38
+ type: "string",
39
+ label: "Address Name",
40
+ description: "The name of the address",
41
+ optional: true,
42
+ },
43
+ addressStreet: {
44
+ type: "string",
45
+ label: "Address Street",
46
+ description: "The street of the address",
47
+ optional: true,
48
+ },
49
+ addressCity: {
50
+ type: "string",
51
+ label: "Address City",
52
+ description: "The city of the address",
53
+ optional: true,
54
+ },
55
+ addressCountryCode: {
56
+ type: "string",
57
+ label: "Address Country Code",
58
+ description: "The country code of the address",
59
+ optional: true,
60
+ },
61
+ },
62
+ async run({ $ }) {
63
+ const response = await this.app.createEvent({
64
+ $,
65
+ data: {
66
+ title: this.title,
67
+ startDate: this.startDate,
68
+ endDate: this.endDate,
69
+ description: this.description,
70
+ location: {
71
+ name: this.addressName,
72
+ street: this.addressStreet,
73
+ city: this.addressCity,
74
+ countryCode: this.addressCountryCode,
75
+ },
76
+ },
77
+ });
78
+
79
+ $.export("$summary", `Successfully created event with ID: ${response.id}`);
80
+
81
+ return response;
82
+ },
83
+ };
84
+
@@ -0,0 +1,43 @@
1
+ export const LIMIT = 100;
2
+
3
+ export const PARTICIPANT_STATUS_OPTIONS = [
4
+ {
5
+ label: "Unanswered",
6
+ value: "UNANSWERED",
7
+ },
8
+ {
9
+ label: "Pending",
10
+ value: "PENDING",
11
+ },
12
+ {
13
+ label: "Valid",
14
+ value: "VALID",
15
+ },
16
+ {
17
+ label: "Reserved",
18
+ value: "RESERVED",
19
+ },
20
+ {
21
+ label: "Confirmed",
22
+ value: "CONFIRMED",
23
+ },
24
+ {
25
+ label: "Declined",
26
+ value: "DECLINED",
27
+ },
28
+ {
29
+ label: "Canceled",
30
+ value: "CANCELED",
31
+ },
32
+ ];
33
+
34
+ export const PARTICIPANT_GENDER_OPTIONS = [
35
+ {
36
+ label: "Male",
37
+ value: "MALE",
38
+ },
39
+ {
40
+ label: "Female",
41
+ value: "FEMALE",
42
+ },
43
+ ];
package/evenium.app.mjs CHANGED
@@ -1,11 +1,111 @@
1
+ import { axios } from "@pipedream/platform";
2
+ import { LIMIT } from "./common/constants.mjs";
3
+
1
4
  export default {
2
5
  type: "app",
3
6
  app: "evenium",
4
- propDefinitions: {},
7
+ propDefinitions: {
8
+ eventId: {
9
+ type: "string",
10
+ label: "Event ID",
11
+ description: "The ID of the event",
12
+ async options({ page }) {
13
+ const { events } = await this.listEvents({
14
+ params: {
15
+ firstResult: (page - 1) * LIMIT,
16
+ maxResults: LIMIT,
17
+ },
18
+ });
19
+
20
+ return events?.map((event) => ({
21
+ label: `${event.title} (${event.id})`,
22
+ value: event.id,
23
+ })) || [];
24
+ },
25
+ },
26
+ },
5
27
  methods: {
6
- // this.$auth contains connected account data
7
- authKeys() {
8
- console.log(Object.keys(this.$auth));
28
+ _baseUrl() {
29
+ return "https://evenium.com/api/1";
30
+ },
31
+ _getHeaders(headers = {}) {
32
+ return {
33
+ "X-Evenium-Token": this.$auth.access_token,
34
+ "Content-Type": "application/json",
35
+ "Accept": "application/json",
36
+ ...headers,
37
+ };
38
+ },
39
+ _makeRequest({
40
+ $ = this, path, headers, ...otherConfig
41
+ } = {}) {
42
+ return axios($, {
43
+ url: `${this._baseUrl()}${path}`,
44
+ headers: this._getHeaders(headers),
45
+ ...otherConfig,
46
+ });
47
+ },
48
+ createEvent({
49
+ data, ...opts
50
+ } = {}) {
51
+ return this._makeRequest({
52
+ method: "POST",
53
+ path: "/events",
54
+ data,
55
+ ...opts,
56
+ });
57
+ },
58
+ listEvents(opts = {}) {
59
+ return this._makeRequest({
60
+ path: "/events",
61
+ ...opts,
62
+ });
63
+ },
64
+ createGuest({
65
+ eventId, ...opts
66
+ } = {}) {
67
+ return this._makeRequest({
68
+ method: "POST",
69
+ path: `/events/${eventId}/guests`,
70
+ ...opts,
71
+ });
72
+ },
73
+ listGuests({
74
+ eventId, ...opts
75
+ } = {}) {
76
+ return this._makeRequest({
77
+ path: `/events/${eventId}/guests`,
78
+ ...opts,
79
+ });
80
+ },
81
+ async *paginate({
82
+ fn, params = {}, maxResults = null, dataField, ...opts
83
+ }) {
84
+ let hasMore = false;
85
+ let count = 0;
86
+ let page = 0;
87
+
88
+ do {
89
+ params.firstResult = page * LIMIT;
90
+ params.maxResults = LIMIT;
91
+
92
+ const {
93
+ [dataField]: data,
94
+ more,
95
+ } = await fn({
96
+ params,
97
+ ...opts,
98
+ });
99
+
100
+ for (const d of data || []) {
101
+ yield d;
102
+
103
+ if (maxResults && ++count === maxResults) {
104
+ return count;
105
+ }
106
+ }
107
+ hasMore = more;
108
+ } while (hasMore);
9
109
  },
10
110
  },
11
111
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/evenium",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Pipedream evenium Components",
5
5
  "main": "evenium.app.mjs",
6
6
  "keywords": [
@@ -13,6 +13,6 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@pipedream/platform": "^3.0.0"
16
+ "@pipedream/platform": "^3.1.1"
17
17
  }
18
18
  }
@@ -0,0 +1,74 @@
1
+ import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
2
+ import evenium from "../../evenium.app.mjs";
3
+
4
+ export default {
5
+ props: {
6
+ evenium,
7
+ db: "$.service.db",
8
+ timer: {
9
+ type: "$.interface.timer",
10
+ default: {
11
+ intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
12
+ },
13
+ },
14
+ },
15
+ methods: {
16
+ _getLastDate() {
17
+ return this.db.get("lastDate");
18
+ },
19
+ _setLastDate(lastDate) {
20
+ this.db.set("lastDate", lastDate);
21
+ },
22
+ getFieldId() {
23
+ throw new Error("getFieldId is not implemented");
24
+ },
25
+ getFunction() {
26
+ throw new Error("getFunction is not implemented");
27
+ },
28
+ getDataField() {
29
+ throw new Error("getDataField is not implemented");
30
+ },
31
+ getArgs() {
32
+ return {};
33
+ },
34
+ async processEvents(maxResults = false) {
35
+ const lastDate = this._getLastDate();
36
+ const fields = this.getFields();
37
+ const response = this.evenium.paginate({
38
+ fn: this.getFunction(),
39
+ ...this.getArgs(),
40
+ dataField: fields.data,
41
+ params: {
42
+ [fields.filter]: lastDate,
43
+ maxResults,
44
+ },
45
+ });
46
+
47
+ const responseArray = [];
48
+ for await (const item of response) {
49
+ responseArray.push(item);
50
+ }
51
+
52
+ if (responseArray.length) {
53
+ this._setLastDate(responseArray[0][fields.date]);
54
+ }
55
+
56
+ for (const result of responseArray.reverse()) {
57
+ this.$emit(result, {
58
+ id: result[fields.id],
59
+ summary: this.getSummary(result),
60
+ ts: Date.parse(result[fields.date]),
61
+ });
62
+ }
63
+ },
64
+ },
65
+ hooks: {
66
+ async deploy() {
67
+ await this.processEvents(10);
68
+ },
69
+ },
70
+ async run() {
71
+ await this.processEvents();
72
+ },
73
+ };
74
+
@@ -0,0 +1,31 @@
1
+ import common from "../common/base-polling.mjs";
2
+ import sampleEmit from "./test-event.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "evenium-new-event",
7
+ name: "New Event",
8
+ description: "Emit new event when a new event is created. [See the documentation](https://static.evenium.com/api-docs/organizer/index-json.html#_get_all_events)",
9
+ version: "0.0.1",
10
+ type: "source",
11
+ dedupe: "unique",
12
+ methods: {
13
+ ...common.methods,
14
+ getFields() {
15
+ return {
16
+ data: "events",
17
+ filter: "createdAfter",
18
+ date: "creationDate",
19
+ id: "id",
20
+ };
21
+ },
22
+ getSummary(result) {
23
+ return `New Event: ${result.title}`;
24
+ },
25
+ getFunction() {
26
+ return this.evenium.listEvents;
27
+ },
28
+ },
29
+ sampleEmit,
30
+ };
31
+
@@ -0,0 +1,10 @@
1
+ export default {
2
+ "id": "16083",
3
+ "title": "Colloque : valoriser et transférer les résultats de la recherche",
4
+ "description": "Séjour au Club Med la Palmyre 600 personnes Anniversaire des 15 ans de la société Arval Phh",
5
+ "startDate": "2010-06-28T08:00:00.000+02:00",
6
+ "endDate": "2010-06-31T18:00:00.000+02:00",
7
+ "creationDate": "2010-04-02T13:02:51.000+02:00",
8
+ "status": "OPEN",
9
+ "url": "/site/colloque-valoriser-et-transferer-les-resultats-de-larecherche"
10
+ }
@@ -0,0 +1,44 @@
1
+ import common from "../common/base-polling.mjs";
2
+ import sampleEmit from "./test-event.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "evenium-new-participant",
7
+ name: "New Participant",
8
+ description: "Emit new event when a new participant (guest) is added to an event. [See the documentation](https://static.evenium.com/api-docs/organizer/index-json.html#_get_all_guests)",
9
+ version: "0.0.1",
10
+ type: "source",
11
+ dedupe: "unique",
12
+ props: {
13
+ ...common.props,
14
+ eventId: {
15
+ propDefinition: [
16
+ common.props.evenium,
17
+ "eventId",
18
+ ],
19
+ },
20
+ },
21
+ methods: {
22
+ ...common.methods,
23
+ getArgs() {
24
+ return {
25
+ eventId: this.eventId,
26
+ };
27
+ },
28
+ getFields() {
29
+ return {
30
+ data: "guests",
31
+ filter: "since",
32
+ date: "lastUpdate",
33
+ id: "guestId",
34
+ };
35
+ },
36
+ getSummary(result) {
37
+ return `New Participant: ${result.firstName} ${result.lastName}`;
38
+ },
39
+ getFunction() {
40
+ return this.evenium.listGuests;
41
+ },
42
+ },
43
+ sampleEmit,
44
+ };
@@ -0,0 +1,80 @@
1
+ export default {
2
+ "contactId": "1003525",
3
+ "eventId": "10574",
4
+ "firstName": "Sophie",
5
+ "lastName": "SERES",
6
+ "gender": "FEMALE",
7
+ "email": "noreply@evenium.com",
8
+ "company": "EVENIUM",
9
+ "lastUpdate": "2009-10-06T18:01:08.000Z",
10
+ "status": "DECLINED",
11
+ "category": "1010",
12
+ "categoryLabel": "Organizor",
13
+ "fields": [{
14
+ "name": "ADDR_CITY",
15
+ "value": "PARIS"
16
+ },{
17
+ "name": "IMPORT_FLAG",
18
+ "value": "Y"
19
+ },{
20
+ "name": "ADDR_STREET_NAME",
21
+ "value": "2, rue de sèze"
22
+ },{
23
+ "name": "1005064",
24
+ "value": "Ile de france"
25
+ },{
26
+ "name": "1005096",
27
+ "value": "3EME Etage"
28
+ },{
29
+ "name": "ADDR_POSTAL_CODE",
30
+ "value": "75009"
31
+ },{
32
+ "eventOnly": "true",
33
+ "name": "1012983",
34
+ "value": "Good"
35
+ },{
36
+ "eventOnly": "true",
37
+ "name": "1013008",
38
+ "value": "Fair"
39
+ },{
40
+ "eventOnly": "true",
41
+ "name": "1013003",
42
+ "value": "Very good"
43
+ },{
44
+ "eventOnly": "true",
45
+ "name": "1012996",
46
+ "value": "Good"
47
+ },{
48
+ "eventOnly": "true",
49
+ "name": "1013007",
50
+ "value": "Good"
51
+ },{
52
+ "eventOnly": "true",
53
+ "name": "1012994",
54
+ "value": "Good"
55
+ },{
56
+ "eventOnly": "true",
57
+ "name": "1012993",
58
+ "value": "Very good"
59
+ },{
60
+ "eventOnly": "true",
61
+ "name": "1013005",
62
+ "value": "Very good"
63
+ },{
64
+ "eventOnly": "true",
65
+ "name": "1012982",
66
+ "value": "Very good"
67
+ },{
68
+ "eventOnly": "true",
69
+ "name": "1012986",
70
+ "value": "Poor"
71
+ },{
72
+ "eventOnly": "true",
73
+ "name": "1012995",
74
+ "value": "Very good"
75
+ },{
76
+ "eventOnly": "true",
77
+ "name": "1013004",
78
+ "value": "Good"
79
+ }]
80
+ }