File tree Expand file tree Collapse file tree 9 files changed +384
-6
lines changed
add-subscriber-to-segmentation-lists
remove-subscriber-from-segmentation-list Expand file tree Collapse file tree 9 files changed +384
-6
lines changed Original file line number Diff line number Diff line change 1+ import { defineAction } from "@pipedream/types" ;
2+ import { parseObject } from "../../common/utils.mjs" ;
3+ import pingback from "../../pingback.app.mjs" ;
4+
5+ export default defineAction ( {
6+ name : "Add Subscriber To Segmentation Lists" ,
7+ description : "Add a subscriber to segmentation lists by email [See the documentation](https://developer.pingback.com/docs/api/add-subscriber-to-segment)" ,
8+ key : "pingback-add-subscriber-to-segmentation-lists" ,
9+ version : "0.0.1" ,
10+ type : "action" ,
11+ props : {
12+ pingback,
13+ email : {
14+ propDefinition : [
15+ pingback ,
16+ "email" ,
17+ ] ,
18+ } ,
19+ segmentationLists : {
20+ propDefinition : [
21+ pingback ,
22+ "segmentationLists" ,
23+ ] ,
24+ } ,
25+ } ,
26+ async run ( { $ } ) {
27+ const response = await this . pingback . addSubscriberToSegmentationLists ( {
28+ $,
29+ email : this . email ,
30+ data : {
31+ segmentationLists : parseObject ( this . segmentationLists ) ,
32+ } ,
33+ } ) ;
34+
35+ $ . export ( "$summary" , `Subscriber ${ this . email } added to segmentation list(s) successfully` ) ;
36+ return response ;
37+ } ,
38+ } ) ;
Original file line number Diff line number Diff line change 1+ import { parseObject } from "../../common/utils.mjs" ;
2+ import pingback from "../../pingback.app.mjs" ;
3+
4+ export default {
5+ name : "Create Subscriber" ,
6+ description : "Create a new subscriber [See the documentation](https://developer.pingback.com/docs/api/create-subscriber)" ,
7+ key : "pingback-create-subscriber" ,
8+ version : "0.0.1" ,
9+ type : "action" ,
10+ props : {
11+ pingback,
12+ email : {
13+ propDefinition : [
14+ pingback ,
15+ "email" ,
16+ ] ,
17+ } ,
18+ phone : {
19+ propDefinition : [
20+ pingback ,
21+ "phone" ,
22+ ] ,
23+ } ,
24+ name : {
25+ propDefinition : [
26+ pingback ,
27+ "name" ,
28+ ] ,
29+ } ,
30+ status : {
31+ propDefinition : [
32+ pingback ,
33+ "status" ,
34+ ] ,
35+ } ,
36+ customFields : {
37+ propDefinition : [
38+ pingback ,
39+ "customFields" ,
40+ ] ,
41+ } ,
42+ segmentationLists : {
43+ propDefinition : [
44+ pingback ,
45+ "segmentationLists" ,
46+ ] ,
47+ } ,
48+ } ,
49+ async run ( { $ } ) {
50+ const response = await this . pingback . createSubscriber ( {
51+ $,
52+ data : {
53+ email : this . email ,
54+ phone : this . phone ,
55+ name : this . name ,
56+ status : this . status ,
57+ customFields : Object . entries ( parseObject ( this . customFields ) ) ?. map ( ( [
58+ key ,
59+ value ,
60+ ] ) => ( {
61+ label : key ,
62+ value,
63+ } ) ) ,
64+ segmentationLists : parseObject ( this . segmentationLists ) ,
65+ } ,
66+ } ) ;
67+
68+ $ . export ( "$summary" , `Subscriber created successfully with ID: ${ response . data . data . id } ` ) ;
69+ return response ;
70+ } ,
71+ } ;
Original file line number Diff line number Diff line change 1+ import { ConfigurationError } from "@pipedream/platform" ;
2+ import pingback from "../../pingback.app.mjs" ;
3+
4+ export default {
5+ name : "Get Subscriber" ,
6+ description : "Get a subscriber by email [See the documentation](https://developer.pingback.com/docs/api/get-subscriber)" ,
7+ key : "pingback-get-subscriber" ,
8+ version : "0.0.1" ,
9+ type : "action" ,
10+ props : {
11+ pingback,
12+ email : {
13+ propDefinition : [
14+ pingback ,
15+ "email" ,
16+ ] ,
17+ } ,
18+ } ,
19+ async run ( { $ } ) {
20+ try {
21+ const response = await this . pingback . getSubscriber ( {
22+ $,
23+ email : this . email ,
24+ } ) ;
25+
26+ $ . export ( "$summary" , `Subscriber retrieved successfully with email: ${ response . data . data . email } ` ) ;
27+ return response ;
28+ } catch ( { response } ) {
29+ throw new ConfigurationError ( response . data . error ) ;
30+ }
31+ } ,
32+ } ;
Original file line number Diff line number Diff line change 1+ import { defineAction } from "@pipedream/types" ;
2+ import pingback from "../../pingback.app.mjs" ;
3+
4+ export default defineAction ( {
5+ name : "Remove Subscriber From Segmentation List" ,
6+ description : "Remove a subscriber from a segmentation list by email [See the documentation](https://developer.pingback.com/docs/api/remove-subscriber-from-segment)" ,
7+ key : "pingback-remove-subscriber-from-segmentation-list" ,
8+ version : "0.0.1" ,
9+ type : "action" ,
10+ props : {
11+ pingback,
12+ email : {
13+ propDefinition : [
14+ pingback ,
15+ "email" ,
16+ ] ,
17+ } ,
18+ segmentationListId : {
19+ propDefinition : [
20+ pingback ,
21+ "segmentationListId" ,
22+ ] ,
23+ type : "string" ,
24+ } ,
25+ } ,
26+ async run ( { $ } ) {
27+ const response = await this . pingback . removeSubscriberFromSegmentationList ( {
28+ $,
29+ email : this . email ,
30+ segmentationListId : this . segmentationListId ,
31+ } ) ;
32+
33+ $ . export ( "$summary" , `Subscriber ${ this . email } removed from segmentation list ${ this . segmentationListId } successfully` ) ;
34+ return response ;
35+ } ,
36+ } ) ;
Original file line number Diff line number Diff line change 1+ import { defineAction } from "@pipedream/types" ;
2+ import { parseObject } from "../../common/utils.mjs" ;
3+ import pingback from "../../pingback.app.mjs" ;
4+
5+ export default defineAction ( {
6+ name : "Update Subscriber" ,
7+ description : "Update a specific subscriber by email [See the documentation](https://developer.pingback.com/docs/api/update-subscriber)" ,
8+ key : "pingback-update-subscriber" ,
9+ version : "0.0.1" ,
10+ type : "action" ,
11+ props : {
12+ pingback,
13+ email : {
14+ propDefinition : [
15+ pingback ,
16+ "email" ,
17+ ] ,
18+ } ,
19+ phone : {
20+ propDefinition : [
21+ pingback ,
22+ "phone" ,
23+ ] ,
24+ } ,
25+ name : {
26+ propDefinition : [
27+ pingback ,
28+ "name" ,
29+ ] ,
30+ } ,
31+ status : {
32+ propDefinition : [
33+ pingback ,
34+ "status" ,
35+ ] ,
36+ } ,
37+ customFields : {
38+ propDefinition : [
39+ pingback ,
40+ "customFields" ,
41+ ] ,
42+ } ,
43+ } ,
44+ async run ( { $ } ) {
45+ const response = await this . pingback . updateSubscriber ( {
46+ $,
47+ email : this . email ,
48+ data : {
49+ phone : this . phone ,
50+ name : this . name ,
51+ status : this . status ,
52+ customFields : Object . entries ( parseObject ( this . customFields ) ) ?. map ( ( [
53+ key ,
54+ value ,
55+ ] ) => ( {
56+ label : key ,
57+ value,
58+ } ) ) ,
59+ } ,
60+ } ) ;
61+
62+ $ . export ( "$summary" , `Subscriber updated successfully with ID: ${ response . data . data . id } ` ) ;
63+ return response ;
64+ } ,
65+ } ) ;
Original file line number Diff line number Diff line change 1+ export const STATUS_OPTIONS = [
2+ {
3+ label : "Free Subscriber" ,
4+ value : "free_subscriber" ,
5+ } ,
6+ {
7+ label : "Paid Subscriber" ,
8+ value : "paid_subscriber" ,
9+ } ,
10+ {
11+ label : "Unsubscribed Subscriber" ,
12+ value : "unsubscribed_subscriber" ,
13+ } ,
14+ ] ;
Original file line number Diff line number Diff line change 1+ export const parseObject = ( obj ) => {
2+ if ( ! obj ) return undefined ;
3+
4+ if ( Array . isArray ( obj ) ) {
5+ return obj . map ( ( item ) => {
6+ if ( typeof item === "string" ) {
7+ try {
8+ return JSON . parse ( item ) ;
9+ } catch ( e ) {
10+ return item ;
11+ }
12+ }
13+ return item ;
14+ } ) ;
15+ }
16+ if ( typeof obj === "string" ) {
17+ try {
18+ return JSON . parse ( obj ) ;
19+ } catch ( e ) {
20+ return obj ;
21+ }
22+ }
23+ return obj ;
24+ } ;
Original file line number Diff line number Diff line change 11{
22 "name" : " @pipedream/pingback" ,
3- "version" : " 0.0.1 " ,
3+ "version" : " 0.1.0 " ,
44 "description" : " Pipedream Pingback Components" ,
55 "main" : " pingback.app.mjs" ,
66 "keywords" : [
1111 "author" :
" Pipedream <[email protected] > (https://pipedream.com/)" ,
1212 "publishConfig" : {
1313 "access" : " public"
14+ },
15+ "dependencies" : {
16+ "@pipedream/platform" : " ^3.1.0"
1417 }
15- }
18+ }
You can’t perform that action at this time.
0 commit comments