warframe-nexus-query 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,65 +0,0 @@
1
- const urls = {
2
- market: process.env.MARKET_URL_OVERRIDE || 'https://api.warframe.market/v1/items',
3
- marketAssets: process.env.MARKET_ASSETS_URL_OVERRIDE || 'https://warframe.market/static/assets/',
4
- };
5
-
6
- /**
7
- * Represents an individual component object of an item.
8
- */
9
- export default class Summary {
10
- /**
11
- * Represents an individual item.
12
- * @param {json} itemData the component data to parse into a summary
13
- * @constructor
14
- */
15
- constructor(itemData) {
16
- this.name = itemData.en.item_name.trim();
17
- this.thumbnail = `${urls.marketAssets}${itemData.thumb}`;
18
- this.partThumb = `${urls.marketAssets}${itemData.sub_icon}`;
19
- this.tradingTax = itemData.trading_tax || 0;
20
- this.ducats = itemData.ducats || 0;
21
- this.masteryLevel = itemData.mastery_level;
22
- this.tradable = itemData.tradable;
23
- this.wikiUrl = itemData.en.wiki_link;
24
- this.codex = itemData.en.codex;
25
- this.description = itemData.en.description.replace(/<\/?p>/gi, '');
26
- this.drops = itemData.en.drop;
27
- this.url = `http://warframe.market/items/${itemData.url_name}`;
28
-
29
- this.type = 'market-v1';
30
- }
31
-
32
- /**
33
- * The components' string representation
34
- * @param {string} opt Option, either 'codex', 'item', 'location', 'all'
35
- * @returns {string}
36
- */
37
- toString(opt = 'item') {
38
- let value = this.name;
39
- if (opt === 'codex' || opt === 'all') {
40
- value += `\`\`\`\nCodex: ${this.codex}\n`;
41
- }
42
- if (opt === 'item' || opt === 'all') {
43
- value +=
44
- `${this.pad(`Requires: ${this.masteryLevel}`, 15)}| Tax: ${this.pad(`${this.tradingTax}cr`)}\n` +
45
- `Item is ${this.tradable ? '' : ' not '} tradable\n` +
46
- `${this.pad(`Sold ${this.prices.soldCount} for ${this.prices.soldPrice}`, 15)}|` +
47
- `Minimum ${this.prices.minimum} | Maximum ${this.prices.maximum}\n`;
48
- }
49
- if (opt === 'location' || opt === 'all') {
50
- value += `${this.pad(`Drops: ${this.drops.map((drop) => drop.name).join(', ')}`, 15)}\n`;
51
- }
52
- value += `\`\`\`\n${this.wikiUrl}`;
53
- return `\u221F${value}`;
54
- }
55
-
56
- pad(str, length = 10, character = ' ') {
57
- let stringRet;
58
- if (str.length < length) {
59
- stringRet = this.pad(`${str}${character}`);
60
- } else {
61
- stringRet = str;
62
- }
63
- return stringRet;
64
- }
65
- }