@activepieces/piece-promotekit 0.1.4

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.
Files changed (83) hide show
  1. package/package.json +17 -0
  2. package/src/i18n/fr.json +76 -0
  3. package/src/i18n/translation.json +76 -0
  4. package/src/index.d.ts +3 -0
  5. package/src/index.d.ts.map +1 -0
  6. package/src/index.js +90 -0
  7. package/src/index.js.map +1 -0
  8. package/src/lib/actions/create-affiliate.d.ts +7 -0
  9. package/src/lib/actions/create-affiliate.d.ts.map +1 -0
  10. package/src/lib/actions/create-affiliate.js +51 -0
  11. package/src/lib/actions/create-affiliate.js.map +1 -0
  12. package/src/lib/actions/create-referral.d.ts +5 -0
  13. package/src/lib/actions/create-referral.d.ts.map +1 -0
  14. package/src/lib/actions/create-referral.js +37 -0
  15. package/src/lib/actions/create-referral.js.map +1 -0
  16. package/src/lib/actions/find-affiliate.d.ts +4 -0
  17. package/src/lib/actions/find-affiliate.d.ts.map +1 -0
  18. package/src/lib/actions/find-affiliate.js +32 -0
  19. package/src/lib/actions/find-affiliate.js.map +1 -0
  20. package/src/lib/actions/find-campaign.d.ts +4 -0
  21. package/src/lib/actions/find-campaign.d.ts.map +1 -0
  22. package/src/lib/actions/find-campaign.js +39 -0
  23. package/src/lib/actions/find-campaign.js.map +1 -0
  24. package/src/lib/actions/find-commission.d.ts +4 -0
  25. package/src/lib/actions/find-commission.d.ts.map +1 -0
  26. package/src/lib/actions/find-commission.js +32 -0
  27. package/src/lib/actions/find-commission.js.map +1 -0
  28. package/src/lib/actions/find-payout.d.ts +4 -0
  29. package/src/lib/actions/find-payout.d.ts.map +1 -0
  30. package/src/lib/actions/find-payout.js +32 -0
  31. package/src/lib/actions/find-payout.js.map +1 -0
  32. package/src/lib/actions/find-referral.d.ts +4 -0
  33. package/src/lib/actions/find-referral.d.ts.map +1 -0
  34. package/src/lib/actions/find-referral.js +32 -0
  35. package/src/lib/actions/find-referral.js.map +1 -0
  36. package/src/lib/actions/list-affiliates.d.ts +5 -0
  37. package/src/lib/actions/list-affiliates.d.ts.map +1 -0
  38. package/src/lib/actions/list-affiliates.js +44 -0
  39. package/src/lib/actions/list-affiliates.js.map +1 -0
  40. package/src/lib/actions/list-campaigns.d.ts +2 -0
  41. package/src/lib/actions/list-campaigns.d.ts.map +1 -0
  42. package/src/lib/actions/list-campaigns.js +35 -0
  43. package/src/lib/actions/list-campaigns.js.map +1 -0
  44. package/src/lib/actions/list-commissions.d.ts +5 -0
  45. package/src/lib/actions/list-commissions.d.ts.map +1 -0
  46. package/src/lib/actions/list-commissions.js +44 -0
  47. package/src/lib/actions/list-commissions.js.map +1 -0
  48. package/src/lib/actions/list-payouts.d.ts +5 -0
  49. package/src/lib/actions/list-payouts.d.ts.map +1 -0
  50. package/src/lib/actions/list-payouts.js +44 -0
  51. package/src/lib/actions/list-payouts.js.map +1 -0
  52. package/src/lib/actions/list-referrals.d.ts +5 -0
  53. package/src/lib/actions/list-referrals.d.ts.map +1 -0
  54. package/src/lib/actions/list-referrals.js +44 -0
  55. package/src/lib/actions/list-referrals.js.map +1 -0
  56. package/src/lib/actions/update-affiliate.d.ts +9 -0
  57. package/src/lib/actions/update-affiliate.d.ts.map +1 -0
  58. package/src/lib/actions/update-affiliate.js +67 -0
  59. package/src/lib/actions/update-affiliate.js.map +1 -0
  60. package/src/lib/common/index.d.ts +27 -0
  61. package/src/lib/common/index.d.ts.map +1 -0
  62. package/src/lib/common/index.js +190 -0
  63. package/src/lib/common/index.js.map +1 -0
  64. package/src/lib/triggers/affiliate-approved.d.ts +11 -0
  65. package/src/lib/triggers/affiliate-approved.d.ts.map +1 -0
  66. package/src/lib/triggers/affiliate-approved.js +75 -0
  67. package/src/lib/triggers/affiliate-approved.js.map +1 -0
  68. package/src/lib/triggers/new-affiliate.d.ts +11 -0
  69. package/src/lib/triggers/new-affiliate.d.ts.map +1 -0
  70. package/src/lib/triggers/new-affiliate.js +75 -0
  71. package/src/lib/triggers/new-affiliate.js.map +1 -0
  72. package/src/lib/triggers/new-commission.d.ts +11 -0
  73. package/src/lib/triggers/new-commission.d.ts.map +1 -0
  74. package/src/lib/triggers/new-commission.js +73 -0
  75. package/src/lib/triggers/new-commission.js.map +1 -0
  76. package/src/lib/triggers/new-referral.d.ts +11 -0
  77. package/src/lib/triggers/new-referral.d.ts.map +1 -0
  78. package/src/lib/triggers/new-referral.js +69 -0
  79. package/src/lib/triggers/new-referral.js.map +1 -0
  80. package/src/lib/triggers/referral-converted.d.ts +11 -0
  81. package/src/lib/triggers/referral-converted.d.ts.map +1 -0
  82. package/src/lib/triggers/referral-converted.js +69 -0
  83. package/src/lib/triggers/referral-converted.js.map +1 -0
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findReferral = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const __1 = require("../..");
8
+ const common_1 = require("../common");
9
+ exports.findReferral = (0, pieces_framework_1.createAction)({
10
+ auth: __1.promotekitAuth,
11
+ name: 'find_referral',
12
+ displayName: 'Find Referral',
13
+ description: 'Get details of a specific referral by ID.',
14
+ props: {
15
+ referral_id: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Referral ID',
17
+ description: 'The ID of the referral to retrieve.',
18
+ required: true,
19
+ }),
20
+ },
21
+ run(context) {
22
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ const response = yield (0, common_1.promotekitApiCall)({
24
+ token: context.auth,
25
+ method: pieces_common_1.HttpMethod.GET,
26
+ path: `/referrals/${context.propsValue.referral_id}`,
27
+ });
28
+ return common_1.promotekitCommon.flattenReferral(response.body.data);
29
+ });
30
+ },
31
+ });
32
+ //# sourceMappingURL=find-referral.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-referral.js","sourceRoot":"","sources":["../../../../src/lib/actions/find-referral.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,6BAAuC;AACvC,sCAAgE;AAEnD,QAAA,YAAY,GAAG,IAAA,+BAAY,EAAC;IACvC,IAAI,EAAE,kBAAc;IACpB,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,2CAA2C;IACxD,KAAK,EAAE;QACL,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC9B,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,qCAAqC;YAClD,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAiB,EAErC;gBACD,KAAK,EAAE,OAAO,CAAC,IAAyB;gBACxC,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,cAAc,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE;aACrD,CAAC,CAAC;YACH,OAAO,yBAAgB,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9D,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const listAffiliates: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ page: import("@activepieces/pieces-framework").NumberProperty<false>;
3
+ limit: import("@activepieces/pieces-framework").NumberProperty<false>;
4
+ }>;
5
+ //# sourceMappingURL=list-affiliates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-affiliates.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/list-affiliates.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc;;;EAiCzB,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listAffiliates = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const __1 = require("../..");
8
+ const common_1 = require("../common");
9
+ exports.listAffiliates = (0, pieces_framework_1.createAction)({
10
+ auth: __1.promotekitAuth,
11
+ name: 'list_affiliates',
12
+ displayName: 'List Affiliates',
13
+ description: 'List all affiliates in your PromoteKit account.',
14
+ props: {
15
+ page: pieces_framework_1.Property.Number({
16
+ displayName: 'Page',
17
+ description: 'Page number to retrieve. Defaults to 1.',
18
+ required: false,
19
+ defaultValue: 1,
20
+ }),
21
+ limit: pieces_framework_1.Property.Number({
22
+ displayName: 'Limit',
23
+ description: 'Number of affiliates per page (max 100). Defaults to 10.',
24
+ required: false,
25
+ defaultValue: 10,
26
+ }),
27
+ },
28
+ run(context) {
29
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
30
+ var _a, _b;
31
+ const response = yield (0, common_1.promotekitApiCall)({
32
+ token: context.auth,
33
+ method: pieces_common_1.HttpMethod.GET,
34
+ path: '/affiliates',
35
+ queryParams: {
36
+ page: String((_a = context.propsValue.page) !== null && _a !== void 0 ? _a : 1),
37
+ limit: String((_b = context.propsValue.limit) !== null && _b !== void 0 ? _b : 10),
38
+ },
39
+ });
40
+ return response.body.data.map(common_1.promotekitCommon.flattenAffiliate);
41
+ });
42
+ },
43
+ });
44
+ //# sourceMappingURL=list-affiliates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-affiliates.js","sourceRoot":"","sources":["../../../../src/lib/actions/list-affiliates.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,6BAAuC;AACvC,sCAAgE;AAEnD,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAE,kBAAc;IACpB,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,iDAAiD;IAC9D,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,yCAAyC;YACtD,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,CAAC;SAChB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACrB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,0DAA0D;YACvE,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,EAAE;SACjB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAiB,EAErC;gBACD,KAAK,EAAE,OAAO,CAAC,IAAyB;gBACxC,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE;oBACX,IAAI,EAAE,MAAM,CAAC,MAAA,OAAO,CAAC,UAAU,CAAC,IAAI,mCAAI,CAAC,CAAC;oBAC1C,KAAK,EAAE,MAAM,CAAC,MAAA,OAAO,CAAC,UAAU,CAAC,KAAK,mCAAI,EAAE,CAAC;iBAC9C;aACF,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAgB,CAAC,gBAAgB,CAAC,CAAC;QACnE,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const listCampaigns: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {}>;
2
+ //# sourceMappingURL=list-campaigns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-campaigns.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/list-campaigns.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa,yHAsBxB,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listCampaigns = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const __1 = require("../..");
8
+ const common_1 = require("../common");
9
+ exports.listCampaigns = (0, pieces_framework_1.createAction)({
10
+ auth: __1.promotekitAuth,
11
+ name: 'list_campaigns',
12
+ displayName: 'List Campaigns',
13
+ description: 'List all campaigns in your PromoteKit account.',
14
+ props: {},
15
+ run(context) {
16
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
+ const response = yield (0, common_1.promotekitApiCall)({
18
+ token: context.auth,
19
+ method: pieces_common_1.HttpMethod.GET,
20
+ path: '/campaigns',
21
+ queryParams: { limit: '100' },
22
+ });
23
+ return response.body.data.map((campaign) => {
24
+ var _a, _b;
25
+ return ({
26
+ id: campaign['id'],
27
+ name: campaign['name'],
28
+ commission_type: (_a = campaign['commission_type']) !== null && _a !== void 0 ? _a : null,
29
+ commission_amount: (_b = campaign['commission_amount']) !== null && _b !== void 0 ? _b : null,
30
+ });
31
+ });
32
+ });
33
+ },
34
+ });
35
+ //# sourceMappingURL=list-campaigns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-campaigns.js","sourceRoot":"","sources":["../../../../src/lib/actions/list-campaigns.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,+DAAyD;AACzD,6BAAuC;AACvC,sCAA8C;AAEjC,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACxC,IAAI,EAAE,kBAAc;IACpB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,gDAAgD;IAC7D,KAAK,EAAE,EAAE;IACH,GAAG,CAAC,OAAO;;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAiB,EAErC;gBACD,KAAK,EAAE,OAAO,CAAC,IAAyB;gBACxC,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;aAC9B,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;;gBAAC,OAAA,CAAC;oBAC3C,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC;oBAClB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC;oBACtB,eAAe,EAAE,MAAA,QAAQ,CAAC,iBAAiB,CAAC,mCAAI,IAAI;oBACpD,iBAAiB,EAAE,MAAA,QAAQ,CAAC,mBAAmB,CAAC,mCAAI,IAAI;iBACzD,CAAC,CAAA;aAAA,CAAC,CAAC;QACN,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const listCommissions: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ page: import("@activepieces/pieces-framework").NumberProperty<false>;
3
+ limit: import("@activepieces/pieces-framework").NumberProperty<false>;
4
+ }>;
5
+ //# sourceMappingURL=list-commissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-commissions.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/list-commissions.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,eAAe;;;EAiC1B,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listCommissions = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const __1 = require("../..");
8
+ const common_1 = require("../common");
9
+ exports.listCommissions = (0, pieces_framework_1.createAction)({
10
+ auth: __1.promotekitAuth,
11
+ name: 'list_commissions',
12
+ displayName: 'List Commissions',
13
+ description: 'List all commissions in your PromoteKit account.',
14
+ props: {
15
+ page: pieces_framework_1.Property.Number({
16
+ displayName: 'Page',
17
+ description: 'Page number to retrieve. Defaults to 1.',
18
+ required: false,
19
+ defaultValue: 1,
20
+ }),
21
+ limit: pieces_framework_1.Property.Number({
22
+ displayName: 'Limit',
23
+ description: 'Number of commissions per page (max 100). Defaults to 10.',
24
+ required: false,
25
+ defaultValue: 10,
26
+ }),
27
+ },
28
+ run(context) {
29
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
30
+ var _a, _b;
31
+ const response = yield (0, common_1.promotekitApiCall)({
32
+ token: context.auth,
33
+ method: pieces_common_1.HttpMethod.GET,
34
+ path: '/commissions',
35
+ queryParams: {
36
+ page: String((_a = context.propsValue.page) !== null && _a !== void 0 ? _a : 1),
37
+ limit: String((_b = context.propsValue.limit) !== null && _b !== void 0 ? _b : 10),
38
+ },
39
+ });
40
+ return response.body.data.map(common_1.promotekitCommon.flattenCommission);
41
+ });
42
+ },
43
+ });
44
+ //# sourceMappingURL=list-commissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-commissions.js","sourceRoot":"","sources":["../../../../src/lib/actions/list-commissions.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,6BAAuC;AACvC,sCAAgE;AAEnD,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,kBAAc;IACpB,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,kDAAkD;IAC/D,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,yCAAyC;YACtD,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,CAAC;SAChB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACrB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,2DAA2D;YACxE,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,EAAE;SACjB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAiB,EAErC;gBACD,KAAK,EAAE,OAAO,CAAC,IAAyB;gBACxC,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,cAAc;gBACpB,WAAW,EAAE;oBACX,IAAI,EAAE,MAAM,CAAC,MAAA,OAAO,CAAC,UAAU,CAAC,IAAI,mCAAI,CAAC,CAAC;oBAC1C,KAAK,EAAE,MAAM,CAAC,MAAA,OAAO,CAAC,UAAU,CAAC,KAAK,mCAAI,EAAE,CAAC;iBAC9C;aACF,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAgB,CAAC,iBAAiB,CAAC,CAAC;QACpE,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const listPayouts: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ page: import("@activepieces/pieces-framework").NumberProperty<false>;
3
+ limit: import("@activepieces/pieces-framework").NumberProperty<false>;
4
+ }>;
5
+ //# sourceMappingURL=list-payouts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-payouts.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/list-payouts.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW;;;EAiCtB,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listPayouts = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const __1 = require("../..");
8
+ const common_1 = require("../common");
9
+ exports.listPayouts = (0, pieces_framework_1.createAction)({
10
+ auth: __1.promotekitAuth,
11
+ name: 'list_payouts',
12
+ displayName: 'List Payouts',
13
+ description: 'List all payouts in your PromoteKit account.',
14
+ props: {
15
+ page: pieces_framework_1.Property.Number({
16
+ displayName: 'Page',
17
+ description: 'Page number to retrieve. Defaults to 1.',
18
+ required: false,
19
+ defaultValue: 1,
20
+ }),
21
+ limit: pieces_framework_1.Property.Number({
22
+ displayName: 'Limit',
23
+ description: 'Number of payouts per page (max 100). Defaults to 10.',
24
+ required: false,
25
+ defaultValue: 10,
26
+ }),
27
+ },
28
+ run(context) {
29
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
30
+ var _a, _b;
31
+ const response = yield (0, common_1.promotekitApiCall)({
32
+ token: context.auth,
33
+ method: pieces_common_1.HttpMethod.GET,
34
+ path: '/payouts',
35
+ queryParams: {
36
+ page: String((_a = context.propsValue.page) !== null && _a !== void 0 ? _a : 1),
37
+ limit: String((_b = context.propsValue.limit) !== null && _b !== void 0 ? _b : 10),
38
+ },
39
+ });
40
+ return response.body.data.map(common_1.promotekitCommon.flattenPayout);
41
+ });
42
+ },
43
+ });
44
+ //# sourceMappingURL=list-payouts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-payouts.js","sourceRoot":"","sources":["../../../../src/lib/actions/list-payouts.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,6BAAuC;AACvC,sCAAgE;AAEnD,QAAA,WAAW,GAAG,IAAA,+BAAY,EAAC;IACtC,IAAI,EAAE,kBAAc;IACpB,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,8CAA8C;IAC3D,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,yCAAyC;YACtD,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,CAAC;SAChB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACrB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,uDAAuD;YACpE,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,EAAE;SACjB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAiB,EAErC;gBACD,KAAK,EAAE,OAAO,CAAC,IAAyB;gBACxC,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE;oBACX,IAAI,EAAE,MAAM,CAAC,MAAA,OAAO,CAAC,UAAU,CAAC,IAAI,mCAAI,CAAC,CAAC;oBAC1C,KAAK,EAAE,MAAM,CAAC,MAAA,OAAO,CAAC,UAAU,CAAC,KAAK,mCAAI,EAAE,CAAC;iBAC9C;aACF,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAgB,CAAC,aAAa,CAAC,CAAC;QAChE,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const listReferrals: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ page: import("@activepieces/pieces-framework").NumberProperty<false>;
3
+ limit: import("@activepieces/pieces-framework").NumberProperty<false>;
4
+ }>;
5
+ //# sourceMappingURL=list-referrals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-referrals.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/list-referrals.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa;;;EAiCxB,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listReferrals = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const __1 = require("../..");
8
+ const common_1 = require("../common");
9
+ exports.listReferrals = (0, pieces_framework_1.createAction)({
10
+ auth: __1.promotekitAuth,
11
+ name: 'list_referrals',
12
+ displayName: 'List Referrals',
13
+ description: 'List all referrals in your PromoteKit account.',
14
+ props: {
15
+ page: pieces_framework_1.Property.Number({
16
+ displayName: 'Page',
17
+ description: 'Page number to retrieve. Defaults to 1.',
18
+ required: false,
19
+ defaultValue: 1,
20
+ }),
21
+ limit: pieces_framework_1.Property.Number({
22
+ displayName: 'Limit',
23
+ description: 'Number of referrals per page (max 100). Defaults to 10.',
24
+ required: false,
25
+ defaultValue: 10,
26
+ }),
27
+ },
28
+ run(context) {
29
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
30
+ var _a, _b;
31
+ const response = yield (0, common_1.promotekitApiCall)({
32
+ token: context.auth,
33
+ method: pieces_common_1.HttpMethod.GET,
34
+ path: '/referrals',
35
+ queryParams: {
36
+ page: String((_a = context.propsValue.page) !== null && _a !== void 0 ? _a : 1),
37
+ limit: String((_b = context.propsValue.limit) !== null && _b !== void 0 ? _b : 10),
38
+ },
39
+ });
40
+ return response.body.data.map(common_1.promotekitCommon.flattenReferral);
41
+ });
42
+ },
43
+ });
44
+ //# sourceMappingURL=list-referrals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-referrals.js","sourceRoot":"","sources":["../../../../src/lib/actions/list-referrals.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,6BAAuC;AACvC,sCAAgE;AAEnD,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACxC,IAAI,EAAE,kBAAc;IACpB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EAAE,gDAAgD;IAC7D,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,yCAAyC;YACtD,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,CAAC;SAChB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACrB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,yDAAyD;YACtE,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,EAAE;SACjB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAiB,EAErC;gBACD,KAAK,EAAE,OAAO,CAAC,IAAyB;gBACxC,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE;oBACX,IAAI,EAAE,MAAM,CAAC,MAAA,OAAO,CAAC,UAAU,CAAC,IAAI,mCAAI,CAAC,CAAC;oBAC1C,KAAK,EAAE,MAAM,CAAC,MAAA,OAAO,CAAC,UAAU,CAAC,KAAK,mCAAI,EAAE,CAAC;iBAC9C;aACF,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAgB,CAAC,eAAe,CAAC,CAAC;QAClE,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const updateAffiliate: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ affiliate_id: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ first_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ last_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
5
+ payout_email: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
+ approved: import("@activepieces/pieces-framework").CheckboxProperty<false>;
7
+ banned: import("@activepieces/pieces-framework").CheckboxProperty<false>;
8
+ }>;
9
+ //# sourceMappingURL=update-affiliate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-affiliate.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/update-affiliate.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,eAAe;;;;;;;EAqD1B,CAAC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateAffiliate = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const __1 = require("../..");
8
+ const common_1 = require("../common");
9
+ exports.updateAffiliate = (0, pieces_framework_1.createAction)({
10
+ auth: __1.promotekitAuth,
11
+ name: 'update_affiliate',
12
+ displayName: 'Update Affiliate',
13
+ description: 'Update an existing affiliate in PromoteKit.',
14
+ props: {
15
+ affiliate_id: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Affiliate ID',
17
+ description: 'The ID of the affiliate to update.',
18
+ required: true,
19
+ }),
20
+ first_name: pieces_framework_1.Property.ShortText({
21
+ displayName: 'First Name',
22
+ required: false,
23
+ }),
24
+ last_name: pieces_framework_1.Property.ShortText({
25
+ displayName: 'Last Name',
26
+ required: false,
27
+ }),
28
+ payout_email: pieces_framework_1.Property.ShortText({
29
+ displayName: 'Payout Email',
30
+ description: 'The email address where the affiliate receives payouts.',
31
+ required: false,
32
+ }),
33
+ approved: pieces_framework_1.Property.Checkbox({
34
+ displayName: 'Approved',
35
+ description: 'Whether the affiliate is approved.',
36
+ required: false,
37
+ }),
38
+ banned: pieces_framework_1.Property.Checkbox({
39
+ displayName: 'Banned',
40
+ description: 'Whether the affiliate is banned.',
41
+ required: false,
42
+ }),
43
+ },
44
+ run(context) {
45
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
46
+ const body = {};
47
+ if (context.propsValue.first_name !== undefined)
48
+ body['first_name'] = context.propsValue.first_name;
49
+ if (context.propsValue.last_name !== undefined)
50
+ body['last_name'] = context.propsValue.last_name;
51
+ if (context.propsValue.payout_email !== undefined)
52
+ body['payout_email'] = context.propsValue.payout_email;
53
+ if (context.propsValue.approved !== undefined)
54
+ body['approved'] = context.propsValue.approved;
55
+ if (context.propsValue.banned !== undefined)
56
+ body['banned'] = context.propsValue.banned;
57
+ const response = yield (0, common_1.promotekitApiCall)({
58
+ token: context.auth,
59
+ method: pieces_common_1.HttpMethod.PUT,
60
+ path: `/affiliates/${context.propsValue.affiliate_id}`,
61
+ body,
62
+ });
63
+ return common_1.promotekitCommon.flattenAffiliate(response.body.data);
64
+ });
65
+ },
66
+ });
67
+ //# sourceMappingURL=update-affiliate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-affiliate.js","sourceRoot":"","sources":["../../../../src/lib/actions/update-affiliate.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAyD;AACzD,6BAAuC;AACvC,sCAAgE;AAEnD,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,kBAAc;IACpB,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,6CAA6C;IAC1D,KAAK,EAAE;QACL,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,oCAAoC;YACjD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,YAAY;YACzB,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,WAAW;YACxB,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,yDAAyD;YACtE,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC1B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,oCAAoC;YACjD,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACxB,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,kCAAkC;YAC/C,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,IAAI,GAA4B,EAAE,CAAC;YACzC,IAAI,OAAO,CAAC,UAAU,CAAC,UAAU,KAAK,SAAS;gBAAE,IAAI,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC;YACpG,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS;gBAAE,IAAI,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC;YACjG,IAAI,OAAO,CAAC,UAAU,CAAC,YAAY,KAAK,SAAS;gBAAE,IAAI,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC;YAC1G,IAAI,OAAO,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS;gBAAE,IAAI,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC9F,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS;gBAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;YAExF,MAAM,QAAQ,GAAG,MAAM,IAAA,0BAAiB,EAErC;gBACD,KAAK,EAAE,OAAO,CAAC,IAAyB;gBACxC,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,eAAe,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE;gBACtD,IAAI;aACL,CAAC,CAAC;YACH,OAAO,yBAAgB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { HttpMethod, HttpMessageBody, HttpResponse } from '@activepieces/pieces-common';
2
+ export declare function promotekitApiCall<T extends HttpMessageBody>({ token, method, path, body, queryParams, }: {
3
+ token: string;
4
+ method: HttpMethod;
5
+ path: string;
6
+ body?: unknown;
7
+ queryParams?: Record<string, string>;
8
+ }): Promise<HttpResponse<T>>;
9
+ export declare function promotekitPaginatedApiCall<T>({ token, path, queryParams, }: {
10
+ token: string;
11
+ path: string;
12
+ queryParams?: Record<string, string>;
13
+ }): Promise<T[]>;
14
+ declare function flattenAffiliate(affiliate: Record<string, unknown>): Record<string, unknown>;
15
+ declare function flattenReferral(referral: Record<string, unknown>): Record<string, unknown>;
16
+ declare function flattenCommission(commission: Record<string, unknown>): Record<string, unknown>;
17
+ declare function flattenPayout(payout: Record<string, unknown>): Record<string, unknown>;
18
+ export declare const promotekitCommon: {
19
+ flattenAffiliate: typeof flattenAffiliate;
20
+ flattenReferral: typeof flattenReferral;
21
+ flattenCommission: typeof flattenCommission;
22
+ flattenPayout: typeof flattenPayout;
23
+ campaignDropdown: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
24
+ affiliateDropdown: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").SecretTextProperty<true>>;
25
+ };
26
+ export {};
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEV,eAAe,EACf,YAAY,EACb,MAAM,6BAA6B,CAAC;AAMrC,wBAAsB,iBAAiB,CAAC,CAAC,SAAS,eAAe,EAAE,EACjE,KAAK,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,WAAW,GACZ,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAW3B;AAID,wBAAsB,0BAA0B,CAAC,CAAC,EAAE,EAClD,KAAK,EACL,IAAI,EACJ,WAAW,GACZ,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAyBf;AAED,iBAAS,gBAAgB,CACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6BzB;AAED,iBAAS,eAAe,CACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAezB;AAED,iBAAS,iBAAiB,CACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqBzB;AAED,iBAAS,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAe/E;AAED,eAAO,MAAM,gBAAgB;;;;;;;CAuE5B,CAAC"}
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.promotekitCommon = void 0;
4
+ exports.promotekitApiCall = promotekitApiCall;
5
+ exports.promotekitPaginatedApiCall = promotekitPaginatedApiCall;
6
+ const tslib_1 = require("tslib");
7
+ const pieces_common_1 = require("@activepieces/pieces-common");
8
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
9
+ const __1 = require("../..");
10
+ const BASE_URL = 'https://www.promotekit.com/api/v1';
11
+ function promotekitApiCall(_a) {
12
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ token, method, path, body, queryParams, }) {
13
+ return yield pieces_common_1.httpClient.sendRequest({
14
+ method,
15
+ url: `${BASE_URL}${path}`,
16
+ authentication: {
17
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
18
+ token,
19
+ },
20
+ queryParams,
21
+ body,
22
+ });
23
+ });
24
+ }
25
+ const MAX_PAGES = 100;
26
+ function promotekitPaginatedApiCall(_a) {
27
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ token, path, queryParams, }) {
28
+ const results = [];
29
+ let page = 1;
30
+ let hasMore = true;
31
+ while (hasMore && page <= MAX_PAGES) {
32
+ const response = yield promotekitApiCall({
33
+ token,
34
+ method: pieces_common_1.HttpMethod.GET,
35
+ path,
36
+ queryParams: Object.assign(Object.assign({}, queryParams), { page: String(page), limit: '100' }),
37
+ });
38
+ results.push(...response.body.data);
39
+ hasMore = response.body.has_more;
40
+ page++;
41
+ }
42
+ return results;
43
+ });
44
+ }
45
+ function flattenAffiliate(affiliate) {
46
+ var _a, _b, _c, _d, _e, _f, _g, _h;
47
+ const campaign = affiliate['campaign'];
48
+ const links = affiliate['links'];
49
+ const promoCodes = affiliate['promo_codes'];
50
+ return {
51
+ id: affiliate['id'],
52
+ email: affiliate['email'],
53
+ first_name: affiliate['first_name'],
54
+ last_name: affiliate['last_name'],
55
+ payout_email: (_a = affiliate['payout_email']) !== null && _a !== void 0 ? _a : null,
56
+ clicks: (_b = affiliate['clicks']) !== null && _b !== void 0 ? _b : 0,
57
+ approved: (_c = affiliate['approved']) !== null && _c !== void 0 ? _c : false,
58
+ banned: (_d = affiliate['banned']) !== null && _d !== void 0 ? _d : false,
59
+ links: links
60
+ ? links.map((l) => `${l['url']} (${l['code']})`).join(', ')
61
+ : null,
62
+ promo_codes: promoCodes
63
+ ? promoCodes.map((p) => p['code']).join(', ')
64
+ : null,
65
+ campaign_id: (_e = campaign === null || campaign === void 0 ? void 0 : campaign['id']) !== null && _e !== void 0 ? _e : null,
66
+ campaign_name: (_f = campaign === null || campaign === void 0 ? void 0 : campaign['name']) !== null && _f !== void 0 ? _f : null,
67
+ campaign_commission_type: (_g = campaign === null || campaign === void 0 ? void 0 : campaign['commission_type']) !== null && _g !== void 0 ? _g : null,
68
+ campaign_commission_amount: (_h = campaign === null || campaign === void 0 ? void 0 : campaign['commission_amount']) !== null && _h !== void 0 ? _h : null,
69
+ created_at: affiliate['created_at'],
70
+ updated_at: affiliate['updated_at'],
71
+ };
72
+ }
73
+ function flattenReferral(referral) {
74
+ var _a, _b, _c, _d, _e, _f, _g;
75
+ const affiliate = referral['affiliate'];
76
+ return {
77
+ id: referral['id'],
78
+ email: referral['email'],
79
+ subscription_status: (_a = referral['subscription_status']) !== null && _a !== void 0 ? _a : null,
80
+ signup_date: (_b = referral['signup_date']) !== null && _b !== void 0 ? _b : null,
81
+ stripe_customer_id: (_c = referral['stripe_customer_id']) !== null && _c !== void 0 ? _c : null,
82
+ affiliate_id: (_d = affiliate === null || affiliate === void 0 ? void 0 : affiliate['id']) !== null && _d !== void 0 ? _d : null,
83
+ affiliate_email: (_e = affiliate === null || affiliate === void 0 ? void 0 : affiliate['email']) !== null && _e !== void 0 ? _e : null,
84
+ affiliate_first_name: (_f = affiliate === null || affiliate === void 0 ? void 0 : affiliate['first_name']) !== null && _f !== void 0 ? _f : null,
85
+ affiliate_last_name: (_g = affiliate === null || affiliate === void 0 ? void 0 : affiliate['last_name']) !== null && _g !== void 0 ? _g : null,
86
+ created_at: referral['created_at'],
87
+ };
88
+ }
89
+ function flattenCommission(commission) {
90
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
91
+ const affiliate = commission['affiliate'];
92
+ const referral = commission['referral'];
93
+ const payout = commission['payout'];
94
+ return {
95
+ id: commission['id'],
96
+ revenue_amount: (_a = commission['revenue_amount']) !== null && _a !== void 0 ? _a : null,
97
+ currency: (_b = commission['currency']) !== null && _b !== void 0 ? _b : null,
98
+ commission_amount: (_c = commission['commission_amount']) !== null && _c !== void 0 ? _c : null,
99
+ payout_status: (_d = commission['payout_status']) !== null && _d !== void 0 ? _d : null,
100
+ referral_date: (_e = commission['referral_date']) !== null && _e !== void 0 ? _e : null,
101
+ stripe_payment_id: (_f = commission['stripe_payment_id']) !== null && _f !== void 0 ? _f : null,
102
+ affiliate_id: (_g = affiliate === null || affiliate === void 0 ? void 0 : affiliate['id']) !== null && _g !== void 0 ? _g : null,
103
+ affiliate_email: (_h = affiliate === null || affiliate === void 0 ? void 0 : affiliate['email']) !== null && _h !== void 0 ? _h : null,
104
+ referral_id: (_j = referral === null || referral === void 0 ? void 0 : referral['id']) !== null && _j !== void 0 ? _j : null,
105
+ referral_email: (_k = referral === null || referral === void 0 ? void 0 : referral['email']) !== null && _k !== void 0 ? _k : null,
106
+ payout_id: (_l = payout === null || payout === void 0 ? void 0 : payout['id']) !== null && _l !== void 0 ? _l : null,
107
+ created_at: commission['created_at'],
108
+ updated_at: commission['updated_at'],
109
+ };
110
+ }
111
+ function flattenPayout(payout) {
112
+ var _a, _b, _c, _d, _e, _f, _g, _h;
113
+ const affiliate = payout['affiliate'];
114
+ return {
115
+ id: payout['id'],
116
+ amount: (_a = payout['amount']) !== null && _a !== void 0 ? _a : null,
117
+ currency: (_b = payout['currency']) !== null && _b !== void 0 ? _b : null,
118
+ status: (_c = payout['status']) !== null && _c !== void 0 ? _c : null,
119
+ affiliate_id: (_d = affiliate === null || affiliate === void 0 ? void 0 : affiliate['id']) !== null && _d !== void 0 ? _d : null,
120
+ affiliate_email: (_e = affiliate === null || affiliate === void 0 ? void 0 : affiliate['email']) !== null && _e !== void 0 ? _e : null,
121
+ affiliate_first_name: (_f = affiliate === null || affiliate === void 0 ? void 0 : affiliate['first_name']) !== null && _f !== void 0 ? _f : null,
122
+ affiliate_last_name: (_g = affiliate === null || affiliate === void 0 ? void 0 : affiliate['last_name']) !== null && _g !== void 0 ? _g : null,
123
+ created_at: payout['created_at'],
124
+ updated_at: (_h = payout['updated_at']) !== null && _h !== void 0 ? _h : null,
125
+ };
126
+ }
127
+ exports.promotekitCommon = {
128
+ flattenAffiliate,
129
+ flattenReferral,
130
+ flattenCommission,
131
+ flattenPayout,
132
+ campaignDropdown: pieces_framework_1.Property.Dropdown({
133
+ auth: __1.promotekitAuth,
134
+ displayName: 'Campaign',
135
+ description: 'Select the campaign for this affiliate.',
136
+ refreshers: [],
137
+ required: false,
138
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
139
+ if (!auth) {
140
+ return {
141
+ disabled: true,
142
+ options: [],
143
+ placeholder: 'Please connect your account first',
144
+ };
145
+ }
146
+ const campaigns = yield promotekitPaginatedApiCall({
147
+ token: auth.secret_text,
148
+ path: '/campaigns',
149
+ });
150
+ return {
151
+ disabled: false,
152
+ options: campaigns.map((c) => ({
153
+ label: c.name,
154
+ value: c.id,
155
+ })),
156
+ };
157
+ }),
158
+ }),
159
+ affiliateDropdown: pieces_framework_1.Property.Dropdown({
160
+ auth: __1.promotekitAuth,
161
+ displayName: 'Affiliate',
162
+ description: 'Select the affiliate.',
163
+ refreshers: [],
164
+ required: true,
165
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
166
+ if (!auth) {
167
+ return {
168
+ disabled: true,
169
+ options: [],
170
+ placeholder: 'Please connect your account first',
171
+ };
172
+ }
173
+ const affiliates = yield promotekitPaginatedApiCall({
174
+ token: auth.secret_text,
175
+ path: '/affiliates',
176
+ });
177
+ return {
178
+ disabled: false,
179
+ options: affiliates.map((a) => {
180
+ var _a, _b;
181
+ return ({
182
+ label: `${(_a = a.first_name) !== null && _a !== void 0 ? _a : ''} ${(_b = a.last_name) !== null && _b !== void 0 ? _b : ''} (${a.email})`.trim(),
183
+ value: a.id,
184
+ });
185
+ }),
186
+ };
187
+ }),
188
+ }),
189
+ };
190
+ //# sourceMappingURL=index.js.map