Files
shields/services/amo/amo-users.service.js
chris48s 93a209f8a4 refactor [amo] service (#2972)
* refactor [amo] service

* change colour
2019-02-10 15:42:35 -06:00

47 lines
892 B
JavaScript

'use strict'
const { metric } = require('../../lib/text-formatters')
const { BaseAmoService, keywords } = require('./amo-base')
module.exports = class AmoUsers extends BaseAmoService {
static get category() {
return 'downloads'
}
static get route() {
return {
base: 'amo/users',
pattern: ':addonId',
}
}
static get examples() {
return [
{
title: 'Mozilla Add-on',
namedParams: { addonId: 'dustman' },
staticPreview: this.render({ users: 750 }),
keywords,
},
]
}
static get defaultBadgeData() {
return {
label: 'users',
}
}
static render({ users }) {
return {
message: metric(users),
color: 'blue',
}
}
async handle({ addonId }) {
const data = await this.fetch({ addonId })
return this.constructor.render({ users: data.addon.daily_users })
}
}