-
Notifications
You must be signed in to change notification settings - Fork 5.5k
17712 actions for hootsuite #17982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
17712 actions for hootsuite #17982
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b19c800
actions for hootsuite #17712
luancazarine 6e81037
pnpm update
luancazarine ee44b67
Fix typos in targeting fields and update description formatting in sc…
luancazarine 195fe34
Update targeting field types and descriptions in schedule-message com…
luancazarine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
components/hootsuite/actions/create-media-upload-job/create-media-upload-job.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { getFileStreamAndMetadata } from "@pipedream/platform"; | ||
import hootsuite from "../../hootsuite.app.mjs"; | ||
|
||
export default { | ||
key: "hootsuite-create-media-upload-job", | ||
name: "Create Media Upload Job", | ||
description: "Creates a new Media Upload Job on your Hootsuite account. [See the documentation](https://apidocs.hootsuite.com/docs/api/index.html#operation/createMedia)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
hootsuite, | ||
file: { | ||
type: "string", | ||
label: "File Path or URL", | ||
description: "The path or URL to the image file.", | ||
}, | ||
syncDir: { | ||
type: "dir", | ||
accessMode: "read", | ||
sync: true, | ||
}, | ||
}, | ||
methods: { | ||
initializeUpload(opts = {}) { | ||
return this.hootsuite._makeRequest({ | ||
method: "POST", | ||
path: "/media", | ||
...opts, | ||
}); | ||
}, | ||
streamToBuffer(stream) { | ||
return new Promise((resolve, reject) => { | ||
const chunks = []; | ||
stream.on("data", (chunk) => chunks.push(chunk)); | ||
stream.on("end", () => resolve(Buffer.concat(chunks))); | ||
stream.on("error", reject); | ||
}); | ||
}, | ||
uploadImage(url, fileBinary, headers) { | ||
return this.hootsuite._makeRequest({ | ||
url, | ||
method: "PUT", | ||
maxBodyLength: Infinity, | ||
data: Buffer.from(fileBinary, "binary"), | ||
noHeaders: true, | ||
headers, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
stream, metadata, | ||
} = await getFileStreamAndMetadata(this.file); | ||
|
||
const { | ||
data: { | ||
uploadUrl, id, | ||
}, | ||
} = await this.initializeUpload({ | ||
data: { | ||
sizeBytes: metadata.size, | ||
mimeType: metadata.contentType, | ||
}, | ||
}); | ||
|
||
const fileBinary = await this.streamToBuffer(stream); | ||
|
||
await this.uploadImage(uploadUrl, fileBinary, { | ||
"Content-Type": metadata.contentType, | ||
}); | ||
|
||
$.export("$summary", `Successfully created media upload job with ID: ${id}`); | ||
return { | ||
fileId: id, | ||
}; | ||
}, | ||
}; |
26 changes: 26 additions & 0 deletions
26
components/hootsuite/actions/get-media-upload-status/get-media-upload-status.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import hootsuite from "../../hootsuite.app.mjs"; | ||
|
||
export default { | ||
key: "hootsuite-get-media-upload-status", | ||
name: "Get Media Upload Status", | ||
description: "Gets the status of a Media Upload Job on your Hootsuite account. [See the documentation](https://apidocs.hootsuite.com/docs/api/index.html#operation/getMedia)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
hootsuite, | ||
fileId: { | ||
type: "string", | ||
label: "File ID", | ||
description: "The ID of the file to get the status of.", | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.hootsuite.getMediaUploadStatus({ | ||
$, | ||
fileId: this.fileId, | ||
}); | ||
|
||
$.export("$summary", `Successfully got media upload status for file ID: ${this.fileId}`); | ||
return response; | ||
}, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.