-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] sproutgigs #10910 #18323
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
20 changes: 20 additions & 0 deletions
20
components/sproutgigs/actions/get-categories/get-categories.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,20 @@ | ||
import app from "../../sproutgigs.app.mjs"; | ||
|
||
export default { | ||
key: "sproutgigs-get-categories", | ||
name: "Get Categories", | ||
description: "Get a list of categories from Sproutgigs. [See the documentation](https://sproutgigs.com/api/documentation.php#gigs-categories)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.getCategories({ | ||
$, | ||
data: {}, | ||
}); | ||
$.export("$summary", "Successfully sent the request. " + response.length + " results retrieved"); | ||
return response; | ||
}, | ||
}; |
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,19 @@ | ||
import app from "../../sproutgigs.app.mjs"; | ||
|
||
export default { | ||
key: "sproutgigs-get-zones", | ||
name: "Get Zones", | ||
description: "Get the available zones. [See the documentation](https://sproutgigs.com/api/documentation.php#jobs-zones)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.getZones({ | ||
$, | ||
}); | ||
$.export("$summary", "Successfully sent the request. " + response.length + " results retrieved"); | ||
return response; | ||
}, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
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,84 @@ | ||
import app from "../../sproutgigs.app.mjs"; | ||
|
||
export default { | ||
key: "sproutgigs-post-job", | ||
name: "Post Job", | ||
description: "Post a new job to Sproutgigs. [See the documentation](https://sproutgigs.com/api/documentation.php#jobs-post)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
test: { | ||
propDefinition: [ | ||
app, | ||
"test", | ||
], | ||
}, | ||
zoneId: { | ||
propDefinition: [ | ||
app, | ||
"zoneId", | ||
], | ||
}, | ||
categoryId: { | ||
propDefinition: [ | ||
app, | ||
"categoryId", | ||
], | ||
}, | ||
title: { | ||
propDefinition: [ | ||
app, | ||
"title", | ||
], | ||
}, | ||
instructions: { | ||
propDefinition: [ | ||
app, | ||
"instructions", | ||
], | ||
}, | ||
proofs: { | ||
propDefinition: [ | ||
app, | ||
"proofs", | ||
], | ||
}, | ||
numTasks: { | ||
propDefinition: [ | ||
app, | ||
"numTasks", | ||
], | ||
}, | ||
taskValue: { | ||
propDefinition: [ | ||
app, | ||
"taskValue", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.postJob({ | ||
$, | ||
data: { | ||
test: this.test | ||
? 1 | ||
: 0, | ||
zone_id: this.zoneId, | ||
category_id: this.categoryId, | ||
title: this.title, | ||
instructions: this.instructions, | ||
proofs: JSON.parse(this.proofs), | ||
num_tasks: this.numTasks, | ||
task_value: this.taskValue, | ||
}, | ||
}); | ||
|
||
if (response.ok === false) { | ||
throw new Error(`Job creation failed: ${response.message}`); | ||
} | ||
|
||
$.export("$summary", "Successfully sent the request. Result message: " + response.message); | ||
return response; | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,15 +1,18 @@ | ||
{ | ||
"name": "@pipedream/sproutgigs", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream SproutGigs Components", | ||
"main": "sproutgigs.app.mjs", | ||
"keywords": [ | ||
"pipedream", | ||
"sproutgigs" | ||
], | ||
"homepage": "https://pipedream.com/apps/sproutgigs", | ||
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)", | ||
"homepage": "https://pipedream.com/apps/sproutgigs", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.1.0" | ||
} | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
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 |
---|---|---|
@@ -1,11 +1,108 @@ | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
type: "app", | ||
app: "sproutgigs", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
test: { | ||
type: "boolean", | ||
label: "Test", | ||
description: "Enable development mode, the job will not be created", | ||
optional: true, | ||
}, | ||
zoneId: { | ||
type: "string", | ||
label: "Zone ID", | ||
description: "Zone ID for the job", | ||
async options() { | ||
const response = await this.getZones(); | ||
return response.map(({ | ||
id, zone, | ||
}) => ({ | ||
value: id, | ||
label: zone, | ||
})); | ||
}, | ||
}, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
categoryId: { | ||
type: "string", | ||
label: "Category ID", | ||
description: "Category ID for the job", | ||
async options() { | ||
const response = await this.getCategories(); | ||
return response.map(({ | ||
id, subcategory, | ||
}) => ({ | ||
value: id, | ||
label: subcategory, | ||
})); | ||
}, | ||
}, | ||
title: { | ||
type: "string", | ||
label: "Title", | ||
description: "Job title", | ||
}, | ||
instructions: { | ||
type: "string[]", | ||
label: "Instructions", | ||
description: "List of expected work steps", | ||
}, | ||
proofs: { | ||
type: "string", | ||
label: "Proofs", | ||
description: "Array of up to 4 proofs, each with description and type (text or screenshot), i.e.: `[{\"description\":\"Profile screenshot\",\"type\":\"screenshot\"}]`", | ||
}, | ||
numTasks: { | ||
type: "integer", | ||
label: "Number of Tasks", | ||
description: "Number of tasks to be performed", | ||
}, | ||
taskValue: { | ||
type: "string", | ||
label: "Task Value", | ||
description: "Amount paid per task", | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
_baseUrl() { | ||
return "https://sproutgigs.com/api"; | ||
}, | ||
async _makeRequest(opts = {}) { | ||
const { | ||
$ = this, | ||
path, | ||
auth, | ||
...otherOpts | ||
} = opts; | ||
return axios($, { | ||
...otherOpts, | ||
url: this._baseUrl() + path, | ||
auth: { | ||
username: `${this.$auth.user_id}`, | ||
password: `${this.$auth.api_secret}`, | ||
...auth, | ||
}, | ||
}); | ||
}, | ||
async postJob(args = {}) { | ||
return this._makeRequest({ | ||
path: "/jobs/post-job.php", | ||
method: "post", | ||
...args, | ||
}); | ||
}, | ||
async getCategories(args = {}) { | ||
return this._makeRequest({ | ||
path: "/jobs/get-categories.php", | ||
...args, | ||
}); | ||
}, | ||
async getZones(args = {}) { | ||
return this._makeRequest({ | ||
path: "/jobs/get-zones.php", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
}; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.