Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions components/streamlabs/actions/create-donation/create-donation.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import streamlabs from "../../streamlabs.app.mjs";
import currencies from "../../common/currencies.mjs";

export default {
key: "streamlabs-create-donation",
name: "Create Donation",
description: "Create a donation for the authenticated user. [See the documentation](https://dev.streamlabs.com/reference/donations-1)",
version: "0.0.1",
type: "action",
props: {
streamlabs,
name: {
type: "string",
label: "Name",
description: "The name of the donor. Has to be between 2-25 length and should only contain utf8 characters",
},
identifier: {
type: "string",
label: "Identifier",
description: "An identifier for this donor, which is used to group donations with the same donor. For example, if you create more than one donation with the same identifier, they will be grouped together as if they came from the same donor. Typically this is best suited as an email address, or a unique hash.",
},
amount: {
type: "string",
label: "Amount",
description: "The amount of this donation",
},
currency: {
type: "string",
label: "Currency",
description: "The 3 letter currency code for this donation. Must be one of the [supported currency codes](https://dev.streamlabs.com/docs/currency-codes)",
options: currencies,
},
message: {
type: "string",
label: "Message",
description: "The message from the donor. Must be < 255 characters",
optional: true,
},
createdAt: {
type: "string",
label: "Created At",
description: "A timestamp that identifies when this donation was made. If left blank, it will default to now. Enter in ISO-8601 format (e.g., `2018-02-18T02:30:00-07:00` or `2018-02-18T08:00:00Z`, where Z stands for UTC)",
optional: true,
},
skipAlert: {
type: "string",
label: "Skip Alert",
description: "Set to `yes` if you need to skip the alert. Default is `no`",
options: [
"yes",
"no",
],
optional: true,
},
},
async run({ $ }) {
const response = await this.streamlabs.createDonation({
$,
data: {
name: this.name,
identifier: this.identifier,
amount: parseFloat(this.amount),
currency: this.currency,
message: this.message,
createdAt: this.createdAt && Date.parse(this.createdAt),
skip_alert: this.skipAlert,
},
});
if (response?.donation_id) {
$.export("$summary", `Successfully created donation with ID: ${response.donation_id}`);
}
return response;
},
};
74 changes: 74 additions & 0 deletions components/streamlabs/actions/send-alert/send-alert.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import streamlabs from "../../streamlabs.app.mjs";

export default {
key: "streamlabs-send-alert",
name: "Send Alert",
description: "Sends an alert to the stream overlay with a custom message, image, and sound. [See the documentation](https://dev.streamlabs.com/reference/alerts)",
version: "0.0.1",
type: "action",
props: {
streamlabs,
type: {
type: "string",
label: "Type",
description: "determines which alert box this alert will show up in",
options: [
"follow",
"subscription",
"donation",
"host",
],
},
message: {
type: "string",
label: "Message",
description: "The message to show with this alert",
},
imageHref: {
type: "string",
label: "Image HREF",
description: "The href pointing to an image resource to play when this alert shows",
optional: true,
},
soundHref: {
type: "string",
label: "Sound HREF",
description: "The href pointing to a sound resource to play when this alert shows",
optional: true,
},
userMessage: {
type: "string",
label: "User Message",
description: "Acting as the second heading, this shows below message",
optional: true,
},
duration: {
type: "string",
label: "Duration",
description: "How many seconds this alert should be displayed. Value should be in milliseconds. Ex: `1000` for 1 second.",
optional: true,
},
specialTextColor: {
type: "string",
label: "Special Text Color",
description: "The color to use for special tokens. Must be a valid CSS color string",
optional: true,
},
},
async run({ $ }) {
const response = await this.streamlabs.sendAlert({
$,
data: {
type: this.type,
message: this.message,
image_href: this.imageHref,
sound_href: this.soundHref,
user_message: this.userMessage,
duration: this.duration,
special_text_color: this.specialTextColor,
},
});
$.export("$summary", `Alert sent with message: ${this.message}`);
return response;
},
};
64 changes: 64 additions & 0 deletions components/streamlabs/actions/send-test-alert/send-test-alert.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import streamlabs from "../../streamlabs.app.mjs";

export default {
key: "streamlabs-send-test-alert",
name: "Send Test Alert",
description: "Send a test alert to the stream overlay in StreamLabs. [See the documentation](https://dev.streamlabs.com/reference/alertssend_test_alert)",
version: "0.0.1",
type: "action",
props: {
streamlabs,
platform: {
type: "string",
label: "Platform",
description: "The streaming platform",
options: [
"twitch",
"youtube",
],
reloadProps: true,
},
},
additionalProps() {
if (!this.platform) {
return {};
}
const props = {
type: {
type: "string",
label: "Type",
description: "The type of the alert",
},
};
if (this.platform === "twitch") {
props.type.options = [
"follow",
"subscription",
"donation",
"host",
"bits",
"raid",
];
}
if (this.platform === "youtube") {
props.type.options = [
"subscription",
"sponsor",
"superchat",
"donation",
];
}
return props;
},
async run({ $ }) {
const response = await this.streamlabs.sendTestAlert({
$,
data: {
platform: this.platform,
type: this.type,
},
});
$.export("$summary", "Successfully sent test alert");
return response;
},
};
90 changes: 90 additions & 0 deletions components/streamlabs/common/currencies.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
export default [
{
value: "USD",
label: "US Dollar",
},
{
value: "AUD",
label: "Australian Dollar",
},
{
value: "BRL",
label: "Brazilian Real",
},
{
value: "CAD",
label: "Canadian Dollar",
},
{
value: "CZK",
label: "Czech Koruna",
},
{
value: "DKK",
label: "Danish Krone",
},
{
value: "EUR",
label: "Euro",
},
{
value: "HKD",
label: "Hong Kong Dollar",
},
{
value: "ILS",
label: "Israeli New Sheqel",
},
{
value: "MYR",
label: "Malaysian Ringgit",
},
{
value: "MXN",
label: "Mexican Peso",
},
{
value: "NOK",
label: "Norwegian Krone",
},
{
value: "NZD",
label: "New Zealand Dollar",
},
{
value: "PHP",
label: "Philippine Peso",
},
{
value: "PLN",
label: "Polish Zloty",
},
{
value: "GBP",
label: "Pound Sterling",
},
{
value: "RUB",
label: "Russian Ruble",
},
{
value: "SGD",
label: "Singapore Dollar",
},
{
value: "SEK",
label: "Swedish Krona",
},
{
value: "CHF",
label: "Swiss Franc",
},
{
value: "THB",
label: "Thai Baht",
},
{
value: "TRY",
label: "Turkish Lira",
},
];
18 changes: 18 additions & 0 deletions components/streamlabs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@pipedream/streamlabs",
"version": "0.0.1",
"description": "Pipedream Streamlabs Components",
"main": "streamlabs.app.mjs",
"keywords": [
"pipedream",
"streamlabs"
],
"homepage": "https://pipedream.com/apps/streamlabs",
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
46 changes: 43 additions & 3 deletions components/streamlabs/streamlabs.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,51 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "streamlabs",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://streamlabs.com/api/v1.0";
},
_accessToken() {
return this.$auth.oauth_access_token;
},
_makeRequest({
$ = this,
path,
data,
...otherOpts
}) {
return axios($, {
...otherOpts,
url: `${this._baseUrl()}${path}`,
data: {
access_token: this._accessToken(),
...data,
},
});
},
sendAlert(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/alerts",
...opts,
});
},
createDonation(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/donations",
...opts,
});
},
sendTestAlert(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/alerts/send_test_alert",
...opts,
});
},
},
};
Loading
Loading