Files
shields/services/amo/amo-base.js
Paul Melnikow 7c226456fe Adopt static fields in [amo] and core (#5440)
Since we've upgraded production to Node 12 (#5436) we can finally adopt static fields!

This starts the process by updating core and one of the service families.
2020-08-19 14:49:29 -04:00

32 lines
785 B
JavaScript

'use strict'
const Joi = require('@hapi/joi')
const { nonNegativeInteger } = require('../validators')
const { BaseJsonService } = require('..')
const keywords = ['amo', 'firefox']
const schema = Joi.object({
average_daily_users: nonNegativeInteger,
current_version: Joi.object({
version: Joi.string().required(),
}).required(),
ratings: Joi.object({
average: Joi.number().required(),
}).required(),
weekly_downloads: nonNegativeInteger,
}).required()
class BaseAmoService extends BaseJsonService {
static defaultBadgeData = { label: 'mozilla add-on' }
async fetch({ addonId }) {
return this._requestJson({
schema,
url: `https://addons.mozilla.org/api/v3/addons/addon/${addonId}`,
})
}
}
module.exports = { BaseAmoService, keywords }