Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions components/sproutgigs/actions/get-categories/get-categories.mjs
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;
},
};
19 changes: 19 additions & 0 deletions components/sproutgigs/actions/get-zones/get-zones.mjs
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;
},
};
84 changes: 84 additions & 0 deletions components/sproutgigs/actions/post-job/post-job.mjs
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;
},
};
7 changes: 5 additions & 2 deletions components/sproutgigs/package.json
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"
}
}
107 changes: 102 additions & 5 deletions components/sproutgigs/sproutgigs.app.mjs
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,
}));
},
},
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,
});
},
},
};
};
11 changes: 8 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading