forked from badges/shields
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deprecate [wheelmap] service (badges#10538)
* deprecate [wheelmap] service * remove app.json
- Loading branch information
Showing
14 changed files
with
18 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,11 @@ | ||
import Joi from 'joi' | ||
import { BaseJsonService, pathParams } from '../index.js' | ||
import { deprecatedService } from '../index.js' | ||
|
||
const schema = Joi.object({ | ||
node: Joi.object({ | ||
wheelchair: Joi.string().required(), | ||
}).required(), | ||
}).required() | ||
|
||
export default class Wheelmap extends BaseJsonService { | ||
static category = 'other' | ||
|
||
static route = { | ||
export const Wheelmap = deprecatedService({ | ||
category: 'other', | ||
route: { | ||
base: 'wheelmap/a', | ||
pattern: ':nodeId(-?[0-9]+)', | ||
} | ||
|
||
static auth = { | ||
passKey: 'wheelmap_token', | ||
authorizedOrigins: ['https://wheelmap.org'], | ||
isRequired: true, | ||
} | ||
|
||
static openApi = { | ||
'/wheelmap/a/{nodeId}': { | ||
get: { | ||
summary: 'Wheelmap', | ||
parameters: pathParams({ | ||
name: 'nodeId', | ||
example: '26699541', | ||
}), | ||
}, | ||
}, | ||
} | ||
|
||
static defaultBadgeData = { label: 'accessibility' } | ||
|
||
static render({ accessibility }) { | ||
let color | ||
if (accessibility === 'yes') { | ||
color = 'brightgreen' | ||
} else if (accessibility === 'limited') { | ||
color = 'yellow' | ||
} else if (accessibility === 'no') { | ||
color = 'red' | ||
} | ||
return { message: accessibility, color } | ||
} | ||
|
||
async fetch({ nodeId }) { | ||
return this._requestJson( | ||
this.authHelper.withQueryStringAuth( | ||
{ passKey: 'api_key' }, | ||
{ | ||
schema, | ||
url: `https://wheelmap.org/api/nodes/${nodeId}`, | ||
httpErrors: { | ||
401: 'invalid token', | ||
404: 'node not found', | ||
}, | ||
}, | ||
), | ||
) | ||
} | ||
|
||
async handle({ nodeId }) { | ||
const json = await this.fetch({ nodeId }) | ||
const accessibility = json.node.wheelchair | ||
return this.constructor.render({ accessibility }) | ||
} | ||
} | ||
pattern: ':nodeId', | ||
}, | ||
label: 'wheelmap', | ||
dateAdded: new Date('2024-09-14'), | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,10 @@ | ||
import { createServiceTester } from '../tester.js' | ||
import { noToken } from '../test-helpers.js' | ||
import _noWheelmapToken from './wheelmap.service.js' | ||
export const t = await createServiceTester() | ||
const noWheelmapToken = noToken(_noWheelmapToken) | ||
|
||
t.create('node with accessibility') | ||
.skipWhen(noWheelmapToken) | ||
import { ServiceTester } from '../tester.js' | ||
export const t = new ServiceTester({ | ||
id: 'Wheelmap', | ||
title: 'Wheelmap', | ||
pathPrefix: '/wheelmap/a', | ||
}) | ||
|
||
t.create('wheelmap (deprecated)') | ||
.get('/26699541.json') | ||
.timeout(7500) | ||
.expectBadge({ | ||
label: 'accessibility', | ||
message: 'yes', | ||
color: 'brightgreen', | ||
}) | ||
|
||
t.create('node with limited accessibility') | ||
.skipWhen(noWheelmapToken) | ||
.get('/2034868974.json') | ||
.timeout(7500) | ||
.expectBadge({ | ||
label: 'accessibility', | ||
message: 'limited', | ||
color: 'yellow', | ||
}) | ||
|
||
t.create('node without accessibility') | ||
.skipWhen(noWheelmapToken) | ||
.get('/-147495158.json') | ||
.timeout(7500) | ||
.expectBadge({ | ||
label: 'accessibility', | ||
message: 'no', | ||
color: 'red', | ||
}) | ||
|
||
t.create('node not found') | ||
.skipWhen(noWheelmapToken) | ||
.get('/0.json') | ||
.timeout(7500) | ||
.expectBadge({ | ||
label: 'accessibility', | ||
message: 'node not found', | ||
}) | ||
.expectBadge({ label: 'wheelmap', message: 'no longer available' }) |