-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[Components] habitica #13284 #17012
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
[Components] habitica #13284 #17012
Changes from all commits
Commits
Show all changes
2 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
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
components/habitica/actions/create-challenge/create-challenge.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,79 @@ | ||
import app from "../../habitica.app.mjs"; | ||
|
||
export default { | ||
key: "habitica-create-challenge", | ||
name: "Create Challenge", | ||
description: "Creates a challenge. [See the documentation](https://habitica.com/apidoc/#api-Challenge-CreateChallenge)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
type: { | ||
propDefinition: [ | ||
app, | ||
"type", | ||
], | ||
}, | ||
group: { | ||
propDefinition: [ | ||
app, | ||
"group", | ||
(c) => ({ | ||
type: c.type, | ||
}), | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
app, | ||
"name", | ||
], | ||
}, | ||
shortName: { | ||
propDefinition: [ | ||
app, | ||
"shortName", | ||
], | ||
}, | ||
summary: { | ||
propDefinition: [ | ||
app, | ||
"summary", | ||
], | ||
}, | ||
description: { | ||
propDefinition: [ | ||
app, | ||
"description", | ||
], | ||
}, | ||
official: { | ||
propDefinition: [ | ||
app, | ||
"official", | ||
], | ||
}, | ||
prize: { | ||
propDefinition: [ | ||
app, | ||
"prize", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.createChallenge({ | ||
$, | ||
data: { | ||
group: this.group, | ||
name: this.name, | ||
shortName: this.shortName, | ||
summary: this.summary, | ||
description: this.description, | ||
official: this.official, | ||
prize: this.prize, | ||
}, | ||
}); | ||
$.export("$summary", "Successfully created challenge with ID: " + response.data._id); | ||
return response; | ||
}, | ||
}; |
26 changes: 26 additions & 0 deletions
26
components/habitica/actions/delete-challenge/delete-challenge.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 app from "../../habitica.app.mjs"; | ||
|
||
export default { | ||
key: "habitica-delete-challenge", | ||
name: "Delete Challenge", | ||
description: "Delete the challenge with the specified ID. [See the documentation](https://habitica.com/apidoc/#api-Challenge-DeleteChallenge)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
challengeId: { | ||
propDefinition: [ | ||
app, | ||
"challengeId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.deleteChallenge({ | ||
$, | ||
challengeId: this.challengeId, | ||
}); | ||
$.export("$summary", "Successfully deleted the challenge with ID: " + this.challengeId); | ||
return response; | ||
}, | ||
}; |
26 changes: 26 additions & 0 deletions
26
components/habitica/actions/get-challenge/get-challenge.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 app from "../../habitica.app.mjs"; | ||
|
||
export default { | ||
key: "habitica-get-challenge", | ||
name: "Get Challenge", | ||
description: "Get data for the challenge with the specified ID. [See the documentation](https://habitica.com/apidoc/#api-Challenge-GetChallenge)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
challengeId: { | ||
propDefinition: [ | ||
app, | ||
"challengeId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.getChallenge({ | ||
$, | ||
challengeId: this.challengeId, | ||
}); | ||
$.export("$summary", "Successfully retrieved the challenge with ID: " + this.challengeId); | ||
return response; | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
export default { | ||
GROUP_TYPES: [ | ||
"party", | ||
"guilds", | ||
"privateGuilds", | ||
"publicGuilds", | ||
"tavern", | ||
], | ||
}; |
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,149 @@ | ||
import { axios } from "@pipedream/platform"; | ||
import constants from "./common/constants.mjs"; | ||
|
||
export default { | ||
type: "app", | ||
app: "habitica", | ||
propDefinitions: { | ||
group: { | ||
type: "string", | ||
label: "Group", | ||
description: "ID of the group to which the challenge belongs", | ||
async options({ type }) { | ||
const response = await this.getGroups({ | ||
type, | ||
}); | ||
const groups = response.data; | ||
return groups.map(({ | ||
name, _id, | ||
}) => ({ | ||
label: name, | ||
value: _id, | ||
})); | ||
}, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
name: { | ||
type: "string", | ||
label: "Name", | ||
description: "Full name of the challenge", | ||
}, | ||
shortName: { | ||
type: "string", | ||
label: "Short Name", | ||
description: "A shortened name for the challenge, to be used as a tag", | ||
}, | ||
summary: { | ||
type: "string", | ||
label: "Summary", | ||
description: "A short summary advertising the main purpose of the challenge", | ||
optional: true, | ||
}, | ||
description: { | ||
type: "string", | ||
label: "Description", | ||
description: "A detailed description of the challenge", | ||
optional: true, | ||
}, | ||
official: { | ||
type: "boolean", | ||
label: "Official", | ||
description: "Whether or not a challenge is an official Habitica challenge", | ||
optional: true, | ||
}, | ||
prize: { | ||
type: "string", | ||
label: "Prize", | ||
description: "Number of gems offered as a prize to challenge winner", | ||
optional: true, | ||
}, | ||
type: { | ||
type: "string", | ||
label: "Type", | ||
description: "Type of the group", | ||
options: constants.GROUP_TYPES, | ||
}, | ||
challengeId: { | ||
type: "string", | ||
label: "Challenge ID", | ||
description: "ID of the challenge to update", | ||
async options({ page }) { | ||
const response = await this.getChallenges({ | ||
params: { | ||
page: page, | ||
}, | ||
}); | ||
const challenges = response.data; | ||
return challenges.map(({ | ||
name, _id, | ||
}) => ({ | ||
label: name, | ||
value: _id, | ||
})); | ||
}, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
}, | ||
methods: { | ||
_baseUrl() { | ||
return "https://habitica.com/api/v3"; | ||
}, | ||
async _makeRequest(opts = {}) { | ||
const { | ||
$ = this, | ||
path, | ||
headers, | ||
...otherOpts | ||
} = opts; | ||
return axios($, { | ||
...otherOpts, | ||
url: this._baseUrl() + path, | ||
headers: { | ||
...headers, | ||
"x-client": "3a326108-1895-4c23-874e-37668c75f2ad-Pipedream", | ||
"x-api-user": `${this.$auth.user_id}`, | ||
"x-api-key": `${this.$auth.api_token}`, | ||
}, | ||
}); | ||
}, | ||
async createChallenge(args = {}) { | ||
return this._makeRequest({ | ||
path: "/challenges", | ||
method: "post", | ||
...args, | ||
}); | ||
}, | ||
async deleteChallenge({ | ||
challengeId, ...args | ||
}) { | ||
return this._makeRequest({ | ||
path: `/challenges/${challengeId}`, | ||
method: "delete", | ||
...args, | ||
}); | ||
}, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
async getChallenge({ | ||
challengeId, ...args | ||
}) { | ||
return this._makeRequest({ | ||
path: `/challenges/${challengeId}`, | ||
...args, | ||
}); | ||
}, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
async getGroups({ | ||
type, ...args | ||
}) { | ||
return this._makeRequest({ | ||
path: "/groups", | ||
params: { | ||
type: type, | ||
}, | ||
...args, | ||
}); | ||
}, | ||
async getChallenges(args = {}) { | ||
return this._makeRequest({ | ||
path: "/challenges/user", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
}; |
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,16 +1,18 @@ | ||
{ | ||
"name": "@pipedream/habitica", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "Pipedream Habitica Components", | ||
"main": "dist/app/habitica.app.mjs", | ||
"main": "habitica.app.mjs", | ||
"keywords": [ | ||
"pipedream", | ||
"habitica" | ||
], | ||
"files": ["dist"], | ||
"homepage": "https://pipedream.com/apps/habitica", | ||
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.1.0" | ||
} | ||
} |
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.