b9d96755ec
* chore(deps-dev): bump prettier from 2.8.8 to 3.0.0 Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.0.0. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.8.8...3.0.0) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * reformat all the things (prettier 3) * update tests to await calls to prettier.format() --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: chris48s <git@chris-shaw.dev>
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
import Joi from 'joi'
|
|
import { BaseJsonService } from '../index.js'
|
|
|
|
const resourceSchema = Joi.object({
|
|
response: Joi.object({
|
|
resource: Joi.object({
|
|
price: Joi.number().required(),
|
|
downloads: Joi.string().required(),
|
|
reviews: Joi.object({
|
|
count: Joi.number().required(),
|
|
stars: Joi.number().required(),
|
|
}).required(),
|
|
updates: Joi.object({
|
|
latest: Joi.object({
|
|
version: Joi.string().required(),
|
|
}).required(),
|
|
}).required(),
|
|
}).required(),
|
|
}).required(),
|
|
}).required()
|
|
|
|
const notFoundResourceSchema = Joi.object({
|
|
response: Joi.object({
|
|
success: Joi.boolean().required(),
|
|
errors: Joi.object().required(),
|
|
}).required(),
|
|
})
|
|
|
|
const resourceFoundOrNotSchema = Joi.alternatives(
|
|
resourceSchema,
|
|
notFoundResourceSchema,
|
|
)
|
|
|
|
const documentation = `
|
|
<p>You can find your resource ID in the url for your resource page.</p>
|
|
<p>Example: <code>https://polymart.org/resource/polymart-plugin.323</code> - Here the Resource ID is 323.</p>`
|
|
|
|
class BasePolymartService extends BaseJsonService {
|
|
async fetch({
|
|
resourceId,
|
|
schema = resourceFoundOrNotSchema,
|
|
url = `https://api.polymart.org/v1/getResourceInfo/?resource_id=${resourceId}`,
|
|
}) {
|
|
return this._requestJson({
|
|
schema,
|
|
url,
|
|
})
|
|
}
|
|
}
|
|
|
|
export { documentation, BasePolymartService }
|