Files
shields/services/bountysource/bountysource.service.js
chris48s b2f47a3303 migrate examples to openApi part 2; affects [archlinux bitcomponents bountysource cdnjs chrome clearlydefined clojars cocoapods coincap] (#9428)
* convert an example that doesn't matter

* migrate some services from examples to openApi

* improve and de-dupe service titles

* revert changes to codefactor
2023-08-08 23:57:47 +00:00

48 lines
1.1 KiB
JavaScript

import Joi from 'joi'
import { metric } from '../text-formatters.js'
import { BaseJsonService, pathParams } from '../index.js'
const schema = Joi.object({ activity_total: Joi.number().required() })
export default class Bountysource extends BaseJsonService {
static category = 'funding'
static route = { base: 'bountysource/team', pattern: ':team/activity' }
static openApi = {
'/bountysource/team/{team}/activity': {
get: {
summary: 'Bountysource',
parameters: pathParams({
name: 'team',
example: 'mozilla-core',
}),
},
},
}
static defaultBadgeData = { label: 'bounties' }
static render({ total }) {
return {
message: metric(total),
color: 'brightgreen',
}
}
async fetch({ team }) {
const url = `https://api.bountysource.com/teams/${team}`
return this._requestJson({
schema,
url,
options: {
headers: { Accept: 'application/vnd.bountysource+json; version=2' },
},
})
}
async handle({ team }) {
const json = await this.fetch({ team })
return this.constructor.render({ total: json.activity_total })
}
}