@pipedream/white_swan 0.0.1 → 0.2.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.
- package/README.md +11 -0
- package/actions/create-pre-fill-info/create-pre-fill-info.mjs +73 -0
- package/actions/get-referred-clients-info/get-referred-clients-info.mjs +33 -0
- package/actions/list-client-email-options/list-client-email-options.mjs +24 -0
- package/actions/submit-complete-plan-request/submit-complete-plan-request.mjs +125 -0
- package/common/constants.mjs +38 -0
- package/common/utils.mjs +28 -0
- package/package.json +5 -1
- package/sources/common/base-polling.mjs +62 -0
- package/sources/new-earnings-event/new-earnings-event.mjs +29 -0
- package/sources/new-personal-plan/new-personal-plan.mjs +27 -0
- package/white_swan.app.mjs +72 -5
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
The White Swan API provides predictive analytics for mitigating risks in financial portfolios using artificial intelligence. By leveraging the White Swan API in Pipedream, you can automate the process of gathering insights, monitoring market conditions, and integrating advanced risk analysis into your existing financial systems. With Pipedream's serverless platform, you can construct workflows to react in real-time to data from White Swan, send alerts, and even automate trades or adjustments based on risk thresholds or predictive signals.
|
|
4
|
+
|
|
5
|
+
# Example Use Cases
|
|
6
|
+
|
|
7
|
+
- **Automated Risk Alerts**: Use White Swan's predictive analytics to monitor portfolio risk and set up a Pipedream workflow that sends you real-time notifications via email, SMS, or Slack when certain risk thresholds are crossed. This immediate feedback allows you to take swift action to mitigate potential losses.
|
|
8
|
+
|
|
9
|
+
- **Dynamic Portfolio Rebalancing**: Create a Pipedream workflow that automatically triggers a rebalancing of your investment portfolio using White Swan's risk predictions. Integrate with a trading platform like Alpaca to execute trades that align your portfolio with the desired risk profile, based on the latest AI-driven insights.
|
|
10
|
+
|
|
11
|
+
- **Market Sentiment Analysis**: Combine White Swan's market sentiment data with sentiment analysis from Twitter or news sources using Pipedream. Correlate the different sentiment indicators and use the results to adjust your investment strategy, or to feed into machine learning models for more nuanced decision-making.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import whiteSwan from "../../white_swan.app.mjs";
|
|
2
|
+
import constants from "../../common/constants.mjs";
|
|
3
|
+
import utils from "../../common/utils.mjs";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
key: "white_swan-create-pre-fill-info",
|
|
7
|
+
name: "Create Pre-fill Info",
|
|
8
|
+
description: "Imports client data for pre-filling applications to enrich the user experience. [See the documentation](https://docs.whiteswan.io/partner-knowledge-base/api-documentation/action-calls/create-pre-fill-information)",
|
|
9
|
+
version: "0.0.2",
|
|
10
|
+
annotations: {
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
openWorldHint: true,
|
|
13
|
+
readOnlyHint: false,
|
|
14
|
+
},
|
|
15
|
+
type: "action",
|
|
16
|
+
props: {
|
|
17
|
+
whiteSwan,
|
|
18
|
+
firstName: {
|
|
19
|
+
type: "string",
|
|
20
|
+
label: "First Name",
|
|
21
|
+
description: "The first name of the intended insured person.",
|
|
22
|
+
optional: true,
|
|
23
|
+
},
|
|
24
|
+
lastName: {
|
|
25
|
+
type: "string",
|
|
26
|
+
label: "Last Name",
|
|
27
|
+
description: "The last name of the intended insured person.",
|
|
28
|
+
optional: true,
|
|
29
|
+
},
|
|
30
|
+
email: {
|
|
31
|
+
type: "string",
|
|
32
|
+
label: "Email",
|
|
33
|
+
description: "The email of the applicant.",
|
|
34
|
+
optional: true,
|
|
35
|
+
},
|
|
36
|
+
address: {
|
|
37
|
+
type: "string",
|
|
38
|
+
label: "Address",
|
|
39
|
+
description: "The current address of the intended insured person.",
|
|
40
|
+
optional: true,
|
|
41
|
+
},
|
|
42
|
+
dateOfBirth: {
|
|
43
|
+
type: "string",
|
|
44
|
+
label: "Date of Birth",
|
|
45
|
+
description: "The date of birth of the intended insured person in ISO 8601 format.",
|
|
46
|
+
optional: true,
|
|
47
|
+
},
|
|
48
|
+
policyType: {
|
|
49
|
+
type: "string",
|
|
50
|
+
label: "Policy Type",
|
|
51
|
+
description: "The policy type of this policy.",
|
|
52
|
+
optional: true,
|
|
53
|
+
options: constants.POLICY_TYPE,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
async run({ $ }) {
|
|
57
|
+
const response = await this.whiteSwan.importClientData({
|
|
58
|
+
$,
|
|
59
|
+
data: {
|
|
60
|
+
first_name: this.firstName,
|
|
61
|
+
last_name: this.lastName,
|
|
62
|
+
email: this.email,
|
|
63
|
+
address: this.address,
|
|
64
|
+
date_of_birth: this.dateOfBirth
|
|
65
|
+
? utils.convertISOToCustomFormat(this.dateOfBirth)
|
|
66
|
+
: undefined,
|
|
67
|
+
policy_type: this.policyType,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
$.export("$summary", "Successfully imported client data for pre-filling applications");
|
|
71
|
+
return response;
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import whiteSwan from "../../white_swan.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "white_swan-get-referred-clients-info",
|
|
5
|
+
name: "Get Referred Clients Info",
|
|
6
|
+
description: "Retrieves information about clients referred from the user's White Swan account. [See the documentation](https://docs.whiteswan.io/partner-knowledge-base/api-documentation/information-calls/referred-client-s)",
|
|
7
|
+
version: "0.0.2",
|
|
8
|
+
annotations: {
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
openWorldHint: true,
|
|
11
|
+
readOnlyHint: true,
|
|
12
|
+
},
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
whiteSwan,
|
|
16
|
+
clientEmail: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
whiteSwan,
|
|
19
|
+
"clientEmail",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
async run({ $ }) {
|
|
24
|
+
const response = await this.whiteSwan.getClients({
|
|
25
|
+
$,
|
|
26
|
+
data: {
|
|
27
|
+
client_email: this.clientEmail,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
$.export("$summary", `Retrieved info for client ${this.clientEmail}`);
|
|
31
|
+
return response;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import white_swan from "../../white_swan.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "white_swan-list-client-email-options",
|
|
5
|
+
name: "List Client Email Options",
|
|
6
|
+
description: "Retrieves available options for the Client Email field.",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
white_swan,
|
|
16
|
+
},
|
|
17
|
+
async run({ $ }) {
|
|
18
|
+
const options = await white_swan.propDefinitions.clientEmail.options.call(this.white_swan);
|
|
19
|
+
$.export("$summary", `Successfully retrieved ${options.length} option${options.length === 1
|
|
20
|
+
? ""
|
|
21
|
+
: "s"}`);
|
|
22
|
+
return options;
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import whiteSwan from "../../white_swan.app.mjs";
|
|
2
|
+
import constants from "../../common/constants.mjs";
|
|
3
|
+
import utils from "../../common/utils.mjs";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
key: "white_swan-submit-complete-plan-request",
|
|
7
|
+
name: "Submit Complete Plan Request",
|
|
8
|
+
description: "Creates a new comprehensive quote request based on the information provided and generates the final quotation without further data requirements. [See the documentation](https://docs.whiteswan.io/partner-knowledge-base/api-documentation/action-calls/submit-complete-plan-request)",
|
|
9
|
+
version: "0.0.2",
|
|
10
|
+
annotations: {
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
openWorldHint: true,
|
|
13
|
+
readOnlyHint: false,
|
|
14
|
+
},
|
|
15
|
+
type: "action",
|
|
16
|
+
props: {
|
|
17
|
+
whiteSwan,
|
|
18
|
+
name: {
|
|
19
|
+
type: "string",
|
|
20
|
+
label: "Name",
|
|
21
|
+
description: "The full name of the person who the request is made on behalf of.",
|
|
22
|
+
},
|
|
23
|
+
email: {
|
|
24
|
+
type: "string",
|
|
25
|
+
label: "Email",
|
|
26
|
+
description: "The email of the person who the request is made on behalf of.",
|
|
27
|
+
},
|
|
28
|
+
policyType: {
|
|
29
|
+
type: "string",
|
|
30
|
+
label: "Policy Type",
|
|
31
|
+
description: "The policy type that this request is made for.",
|
|
32
|
+
options: constants.POLICY_TYPE,
|
|
33
|
+
},
|
|
34
|
+
mainGoal: {
|
|
35
|
+
type: "string",
|
|
36
|
+
label: "Main Goal",
|
|
37
|
+
description: "The primary goal of this plan request, either Protection or Accumulation.",
|
|
38
|
+
options: constants.MAIN_GOAL,
|
|
39
|
+
},
|
|
40
|
+
residentState: {
|
|
41
|
+
type: "string",
|
|
42
|
+
label: "Resident State",
|
|
43
|
+
description: "The state in which the insured person is a resident. Example: `California`",
|
|
44
|
+
},
|
|
45
|
+
deathBenefitNeeded: {
|
|
46
|
+
type: "integer",
|
|
47
|
+
label: "Death Benefit Needed",
|
|
48
|
+
description: "The amount of death benefit that is required for this plan. To opt for the lowest amount possible given a certain premium budget, use 0.",
|
|
49
|
+
default: 0,
|
|
50
|
+
},
|
|
51
|
+
paymentSchedule: {
|
|
52
|
+
type: "string",
|
|
53
|
+
label: "Payment Schedule",
|
|
54
|
+
description: "How often premiums should be paid on this plan.",
|
|
55
|
+
options: constants.PAYMENT_SCHEDULE,
|
|
56
|
+
},
|
|
57
|
+
gender: {
|
|
58
|
+
type: "string",
|
|
59
|
+
label: "Gender",
|
|
60
|
+
description: "Whether the intended insured person is Male or Female.",
|
|
61
|
+
options: constants.GENDER,
|
|
62
|
+
},
|
|
63
|
+
dateOfBirth: {
|
|
64
|
+
type: "string",
|
|
65
|
+
label: "Date of Birth",
|
|
66
|
+
description: "The date of birth of the intended insured person in ISO 8601 format.",
|
|
67
|
+
},
|
|
68
|
+
healthRating: {
|
|
69
|
+
type: "string",
|
|
70
|
+
label: "Health Rating",
|
|
71
|
+
description: "How the insured person would rate their own general health.",
|
|
72
|
+
options: constants.HEALTH_RATING,
|
|
73
|
+
},
|
|
74
|
+
usesTobacco: {
|
|
75
|
+
type: "boolean",
|
|
76
|
+
label: "Uses Tobacco",
|
|
77
|
+
description: "Whether the intended insured person uses tobacco/nicotine products or not.",
|
|
78
|
+
},
|
|
79
|
+
insuredHeightFeet: {
|
|
80
|
+
type: "integer",
|
|
81
|
+
label: "Insured Height in Feet",
|
|
82
|
+
description: "The height in feet of the intended insured person.",
|
|
83
|
+
},
|
|
84
|
+
insuredHeightInches: {
|
|
85
|
+
type: "integer",
|
|
86
|
+
label: "Insured Height in Inches",
|
|
87
|
+
description: "The height in inches of the intended insured person.",
|
|
88
|
+
},
|
|
89
|
+
insuredWeight: {
|
|
90
|
+
type: "integer",
|
|
91
|
+
label: "Insured Weight",
|
|
92
|
+
description: "The weight in pounds of the intended insured person.",
|
|
93
|
+
},
|
|
94
|
+
prefillInfoId: {
|
|
95
|
+
type: "string",
|
|
96
|
+
label: "Pre-fill Info ID",
|
|
97
|
+
description: "If you have already created a pre-fill information you can pass its ID by using this parameter to associate that info with this request.",
|
|
98
|
+
optional: true,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
async run({ $ }) {
|
|
102
|
+
const response = await this.whiteSwan.createQuoteRequest({
|
|
103
|
+
$,
|
|
104
|
+
data: {
|
|
105
|
+
name: this.name,
|
|
106
|
+
email: this.email,
|
|
107
|
+
policy_type: this.policyType,
|
|
108
|
+
main_goal: this.mainGoal,
|
|
109
|
+
resident_state: this.residentState,
|
|
110
|
+
death_benefit: this.deathBenefitNeeded,
|
|
111
|
+
payment_schedule: this.paymentSchedule,
|
|
112
|
+
gender: this.gender,
|
|
113
|
+
date_of_birth: utils.convertISOToCustomFormat(this.dateOfBirth),
|
|
114
|
+
health_rating: this.healthRating,
|
|
115
|
+
tobacco: this.usesTobacco,
|
|
116
|
+
height_feet: this.insuredHeightFeet,
|
|
117
|
+
height_inches: this.insuredHeightInches,
|
|
118
|
+
weight_pounds: this.insuredWeight,
|
|
119
|
+
contact_id: this.prefillInfoId,
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
$.export("$summary", "Successfully submitted complete plan request");
|
|
123
|
+
return response;
|
|
124
|
+
},
|
|
125
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const POLICY_TYPE = [
|
|
2
|
+
"Variable Universal Life",
|
|
3
|
+
"Indexed Universal Life",
|
|
4
|
+
"Whole Life",
|
|
5
|
+
"Term Life",
|
|
6
|
+
"Guaranteed Universal Life",
|
|
7
|
+
"Private Placement Life",
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
const MAIN_GOAL = [
|
|
11
|
+
"Accumulation",
|
|
12
|
+
"Protection",
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const PAYMENT_SCHEDULE = [
|
|
16
|
+
"Monthly",
|
|
17
|
+
"Quarterly",
|
|
18
|
+
"Yearly",
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const GENDER = [
|
|
22
|
+
"Male",
|
|
23
|
+
"Female",
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const HEALTH_RATING = [
|
|
27
|
+
"Average",
|
|
28
|
+
"Good",
|
|
29
|
+
"Excellent",
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
POLICY_TYPE,
|
|
34
|
+
MAIN_GOAL,
|
|
35
|
+
PAYMENT_SCHEDULE,
|
|
36
|
+
GENDER,
|
|
37
|
+
HEALTH_RATING,
|
|
38
|
+
};
|
package/common/utils.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
convertISOToCustomFormat(isoDateString) {
|
|
3
|
+
const date = new Date(isoDateString);
|
|
4
|
+
|
|
5
|
+
const year = date.getFullYear();
|
|
6
|
+
const month = (date.getMonth() + 1).toString().padStart(2, "0");
|
|
7
|
+
const day = date.getDate().toString()
|
|
8
|
+
.padStart(2, "0");
|
|
9
|
+
const hours = date.getHours().toString()
|
|
10
|
+
.padStart(2, "0");
|
|
11
|
+
const minutes = date.getMinutes().toString()
|
|
12
|
+
.padStart(2, "0");
|
|
13
|
+
const seconds = date.getSeconds().toString()
|
|
14
|
+
.padStart(2, "0");
|
|
15
|
+
|
|
16
|
+
const timezoneOffset = -date.getTimezoneOffset();
|
|
17
|
+
const timezoneHours = Math.floor(Math.abs(timezoneOffset) / 60).toString()
|
|
18
|
+
.padStart(2, "0");
|
|
19
|
+
const timezoneMinutes = (Math.abs(timezoneOffset) % 60).toString().padStart(2, "0");
|
|
20
|
+
const timezoneSign = timezoneOffset >= 0
|
|
21
|
+
? "+"
|
|
22
|
+
: "-";
|
|
23
|
+
|
|
24
|
+
const customFormat = `${year}${month}${day}T${hours}${minutes}${seconds}${timezoneSign}${timezoneHours}${timezoneMinutes}`;
|
|
25
|
+
|
|
26
|
+
return customFormat;
|
|
27
|
+
},
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/white_swan",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Pipedream White Swan Components",
|
|
5
5
|
"main": "white_swan.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -11,5 +11,9 @@
|
|
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@pipedream/platform": "^1.6.8",
|
|
17
|
+
"md5": "^2.3.0"
|
|
14
18
|
}
|
|
15
19
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import whiteSwan from "../../white_swan.app.mjs";
|
|
2
|
+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
props: {
|
|
6
|
+
whiteSwan,
|
|
7
|
+
db: "$.service.db",
|
|
8
|
+
timer: {
|
|
9
|
+
type: "$.interface.timer",
|
|
10
|
+
default: {
|
|
11
|
+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
hooks: {
|
|
16
|
+
async deploy() {
|
|
17
|
+
await this.processEvent(25);
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
methods: {
|
|
21
|
+
_getPreviousItems() {
|
|
22
|
+
return this.db.get("previousItems") || {};
|
|
23
|
+
},
|
|
24
|
+
_setPreviousItems(previousItems) {
|
|
25
|
+
this.db.set("previousItems", previousItems);
|
|
26
|
+
},
|
|
27
|
+
async processEvent(max) {
|
|
28
|
+
const previousItems = this._getPreviousItems();
|
|
29
|
+
const resourceFn = this.getResourceFn();
|
|
30
|
+
const items = await resourceFn();
|
|
31
|
+
if (!items?.length) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let count = 0;
|
|
35
|
+
for (const item of items) {
|
|
36
|
+
const itemKey = this.getItemKey(item);
|
|
37
|
+
if (!previousItems[itemKey]) {
|
|
38
|
+
const meta = this.generateMeta(item);
|
|
39
|
+
this.$emit(item, meta);
|
|
40
|
+
previousItems[itemKey] = true;
|
|
41
|
+
count++;
|
|
42
|
+
if (max && count >= max) {
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
this._setPreviousItems(previousItems);
|
|
48
|
+
},
|
|
49
|
+
getResourceFn() {
|
|
50
|
+
throw new Error("getResourceFn is not implemented");
|
|
51
|
+
},
|
|
52
|
+
getItemKey() {
|
|
53
|
+
throw new Error("getItemKey is not implemented");
|
|
54
|
+
},
|
|
55
|
+
generateMeta() {
|
|
56
|
+
throw new Error("generateMeta is not implemented");
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
async run() {
|
|
60
|
+
await this.processEvent();
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import common from "../common/base-polling.mjs";
|
|
2
|
+
import md5 from "md5";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "white_swan-new-earnings-event",
|
|
7
|
+
name: "New Earnings Event",
|
|
8
|
+
description: "Emit new event when a new earnings event is created for your account, such as credits from client referrals or partner payouts.",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
type: "source",
|
|
11
|
+
dedupe: "unique",
|
|
12
|
+
methods: {
|
|
13
|
+
...common.methods,
|
|
14
|
+
getResourceFn() {
|
|
15
|
+
return this.whiteSwan.listEarningsEvents;
|
|
16
|
+
},
|
|
17
|
+
getItemKey(event) {
|
|
18
|
+
return md5(JSON.stringify(event));
|
|
19
|
+
},
|
|
20
|
+
generateMeta(event) {
|
|
21
|
+
const id = this.getItemKey(event);
|
|
22
|
+
return {
|
|
23
|
+
id,
|
|
24
|
+
summary: `New Earnings Event - ${event.event_name}`,
|
|
25
|
+
ts: Date.now(),
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import common from "../common/base-polling.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "white_swan-new-personal-plan",
|
|
6
|
+
name: "New Personal Plan",
|
|
7
|
+
description: "Emit new event when a customer creates a personal plan.",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
type: "source",
|
|
10
|
+
dedupe: "unique",
|
|
11
|
+
methods: {
|
|
12
|
+
...common.methods,
|
|
13
|
+
getResourceFn() {
|
|
14
|
+
return this.whiteSwan.listPersonalPlans;
|
|
15
|
+
},
|
|
16
|
+
getItemKey(plan) {
|
|
17
|
+
return plan.plan_id;
|
|
18
|
+
},
|
|
19
|
+
generateMeta(plan) {
|
|
20
|
+
return {
|
|
21
|
+
id: plan.plan_id,
|
|
22
|
+
summary: `New Plan ${plan.plan_id}`,
|
|
23
|
+
ts: Date.now(),
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
package/white_swan.app.mjs
CHANGED
|
@@ -1,11 +1,78 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
type: "app",
|
|
3
5
|
app: "white_swan",
|
|
4
|
-
propDefinitions: {
|
|
6
|
+
propDefinitions: {
|
|
7
|
+
clientEmail: {
|
|
8
|
+
type: "string",
|
|
9
|
+
label: "Client Email",
|
|
10
|
+
description: "Email of the client to retrieve information",
|
|
11
|
+
async options() {
|
|
12
|
+
const clients = await this.getClients();
|
|
13
|
+
return clients?.map(({
|
|
14
|
+
email: value, name: label,
|
|
15
|
+
}) => ({
|
|
16
|
+
value,
|
|
17
|
+
label,
|
|
18
|
+
})) || [];
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
5
22
|
methods: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
23
|
+
_baseUrl() {
|
|
24
|
+
return "https://app.whiteswan.io/api/1.1/wf";
|
|
25
|
+
},
|
|
26
|
+
_makeRequest(opts = {}) {
|
|
27
|
+
const {
|
|
28
|
+
$ = this,
|
|
29
|
+
path,
|
|
30
|
+
...otherOpts
|
|
31
|
+
} = opts;
|
|
32
|
+
return axios($, {
|
|
33
|
+
...otherOpts,
|
|
34
|
+
url: `${this._baseUrl()}${path}`,
|
|
35
|
+
headers: {
|
|
36
|
+
"Authorization": `Bearer ${this.$auth.api_key}`,
|
|
37
|
+
"Accept": "application/json",
|
|
38
|
+
"Content-Type": "application/json",
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
getClients(opts = {}) {
|
|
43
|
+
return this._makeRequest({
|
|
44
|
+
method: "POST",
|
|
45
|
+
path: "/client",
|
|
46
|
+
...opts,
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
listPersonalPlans(opts = {}) {
|
|
50
|
+
return this._makeRequest({
|
|
51
|
+
path: "/personal_plan",
|
|
52
|
+
method: "POST",
|
|
53
|
+
...opts,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
listEarningsEvents(opts = {}) {
|
|
57
|
+
return this._makeRequest({
|
|
58
|
+
path: "/earnings_event",
|
|
59
|
+
method: "POST",
|
|
60
|
+
...opts,
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
importClientData(opts = {}) {
|
|
64
|
+
return this._makeRequest({
|
|
65
|
+
path: "/new_prefill_info",
|
|
66
|
+
method: "POST",
|
|
67
|
+
...opts,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
createQuoteRequest(opts = {}) {
|
|
71
|
+
return this._makeRequest({
|
|
72
|
+
path: "/complete_request",
|
|
73
|
+
method: "POST",
|
|
74
|
+
...opts,
|
|
75
|
+
});
|
|
9
76
|
},
|
|
10
77
|
},
|
|
11
|
-
};
|
|
78
|
+
};
|