-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
[Components] cincopa #11820
Merged
Merged
[Components] cincopa #11820
Changes from all commits
Commits
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
63 changes: 63 additions & 0 deletions
63
components/cincopa/actions/add-assets-to-gallery/add-assets-to-gallery.mjs
This file contains 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,63 @@ | ||
import app from "../../cincopa.app.mjs"; | ||
import utils from "../../common/utils.mjs"; | ||
|
||
export default { | ||
key: "cincopa-add-assets-to-gallery", | ||
name: "Add Assets to Gallery", | ||
description: "Adds an asset or a list of assets to an existing gallery. [See the documentation](https://www.cincopa.com/media-platform/api-documentation-v2#gallery.add_item)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
fid: { | ||
propDefinition: [ | ||
app, | ||
"fid", | ||
], | ||
}, | ||
rid: { | ||
propDefinition: [ | ||
app, | ||
"rid", | ||
], | ||
}, | ||
insertPosition: { | ||
type: "string", | ||
label: "Insert Position", | ||
description: "Add the assets at the top or the bottom of the gallery. Options: top or bottom (default is `bottom`)", | ||
optional: true, | ||
options: [ | ||
"top", | ||
"bottom", | ||
], | ||
}, | ||
}, | ||
methods: { | ||
addAssetToGallery(args = {}) { | ||
return this.app._makeRequest({ | ||
path: "/gallery.add_item.json", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
addAssetToGallery, | ||
fid, | ||
rid, | ||
insertPosition, | ||
} = this; | ||
|
||
const response = await addAssetToGallery({ | ||
$, | ||
params: { | ||
fid, | ||
rid: utils.parseArray(rid).join(","), | ||
insert_position: insertPosition, | ||
}, | ||
}); | ||
|
||
$.export("$summary", "Successfully added assets to gallery"); | ||
return response; | ||
}, | ||
}; |
57 changes: 57 additions & 0 deletions
57
components/cincopa/actions/create-gallery/create-gallery.mjs
This file contains 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,57 @@ | ||
import app from "../../cincopa.app.mjs"; | ||
|
||
export default { | ||
key: "cincopa-create-gallery", | ||
name: "Create Gallery", | ||
description: "Creates a new gallery, returning the new gallery FID (unique ID). [See the documentation](https://www.cincopa.com/media-platform/api-documentation-v2#gallery.create)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
name: { | ||
type: "string", | ||
label: "Name", | ||
description: "Name of the gallery", | ||
}, | ||
description: { | ||
type: "string", | ||
label: "Description", | ||
description: "Description of the gallery", | ||
optional: true, | ||
}, | ||
template: { | ||
type: "string", | ||
label: "Template", | ||
description: "Set the gallery skin to this template", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
createGallery(args = {}) { | ||
return this.app._makeRequest({ | ||
path: "/gallery.create.json", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
createGallery, | ||
name, | ||
description, | ||
template, | ||
} = this; | ||
|
||
const response = await createGallery({ | ||
$, | ||
params: { | ||
name, | ||
description, | ||
template, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created gallery with FID \`${response.fid}\``); | ||
return response; | ||
}, | ||
}; |
57 changes: 57 additions & 0 deletions
57
components/cincopa/actions/upload-asset-from-url/upload-asset-from-url.mjs
This file contains 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,57 @@ | ||
import app from "../../cincopa.app.mjs"; | ||
|
||
export default { | ||
key: "cincopa-upload-asset-from-url", | ||
name: "Upload Asset From URL", | ||
description: "Upload an asset from an input URL to a Cincopa gallery. [See the documentation](https://www.cincopa.com/media-platform/api-documentation-v2#asset_upload_from_url)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
input: { | ||
type: "string", | ||
label: "Input URL", | ||
description: "Input URL for the source asset to upload", | ||
}, | ||
fid: { | ||
propDefinition: [ | ||
app, | ||
"fid", | ||
], | ||
}, | ||
type: { | ||
type: "string", | ||
label: "Type", | ||
description: "Type of the attached asset", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
uploadAssetFromUrl(args = {}) { | ||
return this.app._makeRequest({ | ||
path: "/asset.upload_from_url.json", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
uploadAssetFromUrl, | ||
input, | ||
fid, | ||
type, | ||
} = this; | ||
|
||
const response = await uploadAssetFromUrl({ | ||
$, | ||
params: { | ||
input, | ||
fid, | ||
type, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully uploaded asset from URL with status ID \`${response.status_id}\``); | ||
return response; | ||
}, | ||
}; |
This file contains 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 |
---|---|---|
@@ -1,11 +1,82 @@ | ||
import { axios } from "@pipedream/platform"; | ||
import constants from "./common/constants.mjs"; | ||
|
||
export default { | ||
type: "app", | ||
app: "cincopa", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
fid: { | ||
type: "string", | ||
label: "Gallery FID", | ||
description: "Gallery FID to add the assets", | ||
async options({ page }) { | ||
const { galleries } = await this.listGalleries({ | ||
params: { | ||
page: page + 1, | ||
}, | ||
}); | ||
return galleries.map(({ | ||
fid: value, name: label, | ||
}) => ({ | ||
value, | ||
label, | ||
})); | ||
}, | ||
}, | ||
rid: { | ||
type: "string[]", | ||
label: "Asset RIDs", | ||
description: "List of RIDs (assets id) to be added", | ||
optional: true, | ||
useQuery: true, | ||
async options({ | ||
query: search, page, | ||
}) { | ||
const { items } = await this.listAssets({ | ||
params: { | ||
search, | ||
page: page + 1, | ||
}, | ||
}); | ||
return items.map(({ | ||
rid: value, filename: label, | ||
}) => ({ | ||
value, | ||
label, | ||
})); | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
getUrl(path) { | ||
return `${constants.BASE_URL}${constants.VERSION_PATH}${path}`; | ||
}, | ||
getAuthParams(params) { | ||
return { | ||
...params, | ||
api_token: this.$auth.api_token, | ||
}; | ||
}, | ||
_makeRequest({ | ||
$ = this, path, params, ...args | ||
} = {}) { | ||
return axios($, { | ||
...args, | ||
url: this.getUrl(path), | ||
params: this.getAuthParams(params), | ||
}); | ||
}, | ||
listGalleries(args = {}) { | ||
return this._makeRequest({ | ||
path: "/gallery.list.json", | ||
...args, | ||
}); | ||
}, | ||
listAssets(args = {}) { | ||
return this._makeRequest({ | ||
path: "/asset.list.json", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
}; |
This file contains 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,11 @@ | ||
const BASE_URL = "https://api.cincopa.com"; | ||
const VERSION_PATH = "/v2"; | ||
const SECURITY_KEY = "securityKey"; | ||
const DEFAULT_MAX = 600; | ||
|
||
export default { | ||
BASE_URL, | ||
VERSION_PATH, | ||
SECURITY_KEY, | ||
DEFAULT_MAX, | ||
}; |
This file contains 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,28 @@ | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
|
||
function parseArray(value) { | ||
try { | ||
if (!value) { | ||
return []; | ||
} | ||
|
||
if (Array.isArray(value)) { | ||
return value; | ||
} | ||
|
||
const parsedValue = JSON.parse(value); | ||
|
||
if (!Array.isArray(parsedValue)) { | ||
throw new Error("Not an array"); | ||
} | ||
|
||
return parsedValue; | ||
|
||
} catch (e) { | ||
throw new ConfigurationError("Make sure the custom expression contains a valid array object"); | ||
} | ||
} | ||
|
||
export default { | ||
parseArray, | ||
}; |
This file contains 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,19 @@ | ||
{ | ||
"name": "@pipedream/cincopa", | ||
"version": "0.0.1", | ||
"description": "Pipedream Cincopa Components", | ||
"main": "cincopa.app.mjs", | ||
"keywords": [ | ||
"pipedream", | ||
"cincopa" | ||
], | ||
"homepage": "https://pipedream.com/apps/cincopa", | ||
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)", | ||
"dependencies": { | ||
"@pipedream/platform": "^1.6.5", | ||
"uuid": "^8.3.2" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
components/cincopa/sources/asset-uploaded-instant/asset-uploaded-instant.mjs
This file contains 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,25 @@ | ||
import common from "../common/webhook.mjs"; | ||
import events from "../common/events.mjs"; | ||
|
||
export default { | ||
...common, | ||
key: "cincopa-asset-uploaded-instant", | ||
name: "New Asset Uploaded (Instant)", | ||
description: "Emit new event when a new asset is uploaded. [See the documentation](https://www.cincopa.com/media-platform/api-documentation-v2#webhook.set)", | ||
version: "0.0.1", | ||
type: "source", | ||
dedupe: "unique", | ||
methods: { | ||
...common.methods, | ||
getEvents() { | ||
return events.ASSET_UPLOADED; | ||
}, | ||
generateMeta(resource) { | ||
return { | ||
id: resource.id, | ||
summary: `New Asset: ${resource.filename}`, | ||
ts: Date.parse(resource.modified), | ||
}; | ||
}, | ||
}, | ||
}; |
This file contains 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,15 @@ | ||
export default { | ||
GALLERY_ALL: "gallery.*", | ||
GALLERY_CREATED: "gallery.created", | ||
GALLERY_UPDATED: "gallery.updated", | ||
GALLERY_DELETED: "gallery.deleted", | ||
GALLERY_CLAIM: "gallery.claim", | ||
GALLERY_SYNC: "gallery.sync", | ||
GALLERY_SYNCED: "gallery.synced", | ||
ASSET_ALL: "asset.*", | ||
ASSET_UPLOADED: "asset.uploaded", | ||
ASSET_SYNCED: "asset.synced", | ||
ACCOUNT_ALL: "account.*", | ||
ANALYTICS_ALL: "analytics.*", | ||
LEADS_ALL: "leads.*", | ||
}; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.