Skip to content

Commit

Permalink
deprecate [beerpay] (#6708)
Browse files Browse the repository at this point in the history
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
  • Loading branch information
chris48s and repo-ranger[bot] authored Jul 3, 2021
1 parent d4ce24b commit 90831e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 54 deletions.
52 changes: 11 additions & 41 deletions services/beerpay/beerpay.service.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,13 @@
'use strict'

const Joi = require('joi')
const { BaseJsonService } = require('..')

const schema = Joi.object({
total_amount: Joi.number().min(0).required(),
}).required()

module.exports = class Beerpay extends BaseJsonService {
static category = 'funding'
static route = { base: 'beerpay', pattern: ':user/:project' }

static examples = [
{
title: 'Beerpay',
namedParams: { user: 'hashdog', project: 'scrapfy-chrome-extension' },
staticPreview: this.render({ totalAmount: 10 }),
},
]

static defaultBadgeData = { label: 'beerpay' }

static render({ totalAmount }) {
return {
message: `$${totalAmount}`,
color: totalAmount > 0 ? 'blue' : 'red',
}
}

async handle({ user, project }) {
// e.g. JSON response: https://beerpay.io/api/v1/beerpay/projects/beerpay.io
// e.g. SVG badge: https://beerpay.io/beerpay/beerpay.io/badge.svg?style=flat-square
const { total_amount: totalAmount } = await this._requestJson({
schema,
url: `https://beerpay.io/api/v1/${user}/projects/${project}`,
errorMessages: {
404: 'project not found',
},
})
return this.constructor.render({ totalAmount })
}
}
const { deprecatedService } = require('..')

module.exports = deprecatedService({
category: 'build',
route: {
base: 'beerpay',
pattern: ':various+',
},
label: 'beerpay',
dateAdded: new Date('2021-07-03'),
})
22 changes: 9 additions & 13 deletions services/beerpay/beerpay.tester.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
'use strict'

const { withRegex } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())

const amountOfMoney = withRegex(/^\$[0-9]+(\.[0-9]+)?/)

t.create('funding').get('/hashdog/scrapfy-chrome-extension.json').expectBadge({
label: 'beerpay',
message: amountOfMoney,
})

t.create('funding (unknown project)')
.get('/hashdog/not-a-real-project.json')
const { ServiceTester } = require('../tester')
const t = (module.exports = new ServiceTester({
id: 'beerpay',
title: 'Beerpay',
}))

t.create('no longer available (previously beerpay)')
.get('/hashdog/scrapfy-chrome-extension.json')
.expectBadge({
label: 'beerpay',
message: 'project not found',
message: 'no longer available',
})

0 comments on commit 90831e6

Please sign in to comment.