node-blizzard-caller
v1.3.1
Published
A node webservice caller for blizzard API
Downloads
10
Readme
Index
Installation
npm install --save node-blizzard-caller@beta
How to use
Simply instanciate a WarcraftCaller
:
import { Callers } from 'node-blizzard-caller';
const battleNetApiKey = 'YOUR BATTLE.NET API KEY';
const warcraftCaller = new Callers.WarcraftCaller({ apiKey: battleNetApiKey });
Environment variables
Callers from discard automatically try to load some informations from environments variables:
BATTLENET_CLIENT_ID
: the battle.net client idBATTLENET_CLIENT_SECRET
: the battle.net client secretBLIZZARD_CALLER_REGION
: the battle.net region to useBLIZZARD_CALLER_LOCALE
: the battle.net locale to use
It can be override by providing as first param this kind of config:
{
"apiKey": "",
"region": "",
"locale": ""
}
There is a fallback to eu
region if not provided and to each region default locale if locale not provided
Events
Callers extends EventEmitter
and emit 2 events which you can listen on:
import { Events } from 'node-blizzard-caller/lib/caller/WarcraftCaller';
warcraftCaller.on(Events.Call, (url) => {
// url is the full URL called by discard
});
warcraftCaller.on(Events.Error, (err) => {
// describe itself
});
Region & locale helper
import { Localization } from 'node-blizzard-caller';
// All available regions (typescript enum)
const regions = Localization.Region;
const region = regions.us;
// All available locales per regions (typescript enum)
const locales = Localization.Locale;
// Region's default locale
const locale = locales[ region ].default;
// Other locales
const locale = locales.es_MX;
Further reading
Contributors
- Senorihl [email protected]
License
- Apache-2.0 : http://opensource.org/licenses/Apache-2.0