with Bókun and Pipedream Utils?
Get memory usage statistics for the current Pipedream workflow.
Convert an object to a JSON format string
Add or subtract time from a given input
Get the duration between two dates in days, hours, minutes, and seconds along with checking if they are the same.
import { axios } from "@pipedream/platform";
import crypto from "crypto";
export default defineComponent({
props: {
bokun: {
type: "app",
app: "bokun",
}
},
async run({ steps, $ }) {
const getBokunHeaders = function (accessKey, secretKey, path = "", method = "GET") {
// Format current date in UTC
const now = new Date();
const date = now.toISOString()
.replace('T', ' ')
.replace(/\.\d+Z$/, '');
// Normalize method
const httpMethod = method.toUpperCase();
// Concatenate string for signature
const stringToSign = date + accessKey + httpMethod + path;
// Create HMAC-SHA1 signature
const hmac = crypto.createHmac('sha1', secretKey);
hmac.update(stringToSign);
const signature = hmac.digest('base64');
// Return headers and debug info
return {
headers: {
"X-Bokun-Date": date,
"X-Bokun-AccessKey": accessKey,
"X-Bokun-Signature": signature,
"Content-Type": "application/json"
},
debug: {
date,
stringToSign,
signature
}
};
};
const path= "/restapi/v2.0/marketplace/vendor/self/";
const headers = getBokunHeaders(
this.bokun.$auth.access_key,
this.bokun.$auth.secret_key,
path).headers;
// Make API request
const response = await axios($, {
method: "GET", // must match the method you specified when generating headers
url: `${this.bokun.$auth.api_url}${path}`,
headers,
});
return response;
},
})
The Pipedream Utils app is a set of pre-built functions that streamline common tasks in your workflows. It acts like a Swiss Army knife for developers, providing essential tools such as format conversion, date manipulation, and text processing. By leveraging these functions, you can reduce the boilerplate code needed for routine operations, speeding up the development of intricate automations. The Helper Functions API can be a game changer when it comes to tasks like parsing dates in user-friendly formats, encoding and decoding data, or generating UUIDs, making them more efficient and less error-prone.
export default defineComponent({
props: {
pipedream_utils: {
type: "app",
app: "pipedream_utils",
}
},
async run({steps, $}) {
},
})