with Printful (OAuth) and MQTT?
The Printful (OAuth) API on Pipedream allows you to automate and integrate Printful's on-demand printing and warehousing services into your custom workflows. From syncing e-commerce orders to generating custom notifications on order status updates, you can tailor the Printful API to fit seamlessly into your business processes. This integration is ideal for e-commerce businesses looking to streamline their operations, especially for those who want to synchronize their storefronts with Printful's production pipeline without extensive manual oversight.
import { axios } from "@pipedream/platform"
export default defineComponent({
props: {
printful_oauth: {
type: "app",
app: "printful_oauth",
}
},
async run({steps, $}) {
return await axios($, {
url: `https://api.printful.com/oauth/scopes`,
headers: {
Authorization: `Bearer ${this.printful_oauth.$auth.oauth_access_token}`,
},
})
},
})
import mqtt from "mqtt";
export default defineComponent({
props: {
mqtt: {
type: "app",
app: "mqtt",
}
},
async run({ steps, $ }) {
const url = `${this.mqtt.$auth.protocol}://${this.mqtt.$auth.host}:${this.mqtt.$auth.port}`;
const options = {
clientId: this.mqtt.$auth.client_id ?? `pipedream-client-${Date.now()}`,
connectTimeout: 5000,
username: this.mqtt.$auth.username,
password: this.mqtt.$auth.password,
};
const client = mqtt.connect(url, options);
await new Promise((resolve) => {
client.on("connect", () => {
client.publish("pipedream/test", 'Welcome MQTT + Pipedream users! ' + new Date().toISOString(), () => {
client.end();
console.log("Message sent");
resolve();
});
});
});
return {
mqttClientIsConnected: client.connected,
};
},
})