@@ -11,24 +11,29 @@ const resources = require('./resources/'),
1111
1212class XIVAPI {
1313 /*{
14- language string 'en' optional
15- staging bool false optional
16- snake_case bool false optional
14+ private_key string undefined optional
15+ language string 'en' optional
16+ staging bool false optional
17+ snake_case bool false optional
1718 }
1819 */
19- constructor ( apikey , options = { } ) {
20- if ( typeof ( apikey ) === 'undefined' )
21- throw Error ( 'The apikey must be defined.' )
20+ constructor ( options = { } , legacyOptions = { } ) {
21+ //handle attempted use of old API key
22+ if ( typeof ( options ) === 'string' ) {
23+ console . error ( '[xivapi-js] BREAKING CHANGE:\n\
24+ The previous API keys for XIVAPI have been phased out, and are no longer mandatory. \
25+ This means you\'ll have to define your key during initialization slightly differently. \
26+ See how in https://github.com/xivapi/xivapi-js/releases/tag/v0.1.3.\n\
27+ **This instance of xivapi-js will run WITHOUT an API key**' )
28+ options = legacyOptions
29+ }
2230
2331 this . endpoint = `https://${ options . staging ? 'staging.' : '' } xivapi.com`
24- this . globalParams = {
25- key : apikey ,
26- language : options . language || 'en' ,
27- snake_case : options . snake_case
28- }
29- if ( ! resources . languages . includes ( this . globalParams . language ) )
32+ if ( options . language && ! resources . languages . includes ( options . language ) )
3033 throw Error ( `Invalid language given, must be: ${ this . resources . languages } ` )
3134
35+ this . globalParams = options
36+
3237 this . resources = resources
3338
3439 this . search = Search . bind ( this )
0 commit comments