ksoft.js
Advanced tools
Comparing version 1.0.3 to 1.0.7
@@ -120,2 +120,6 @@ /** | ||
* @prop {geoipData} data The data object for geoip data | ||
* | ||
* @typedef {Object} convertCurrencyResponse The response for kumo.convertCurrency | ||
* @prop {Number} value The value in the convert to type parameter | ||
* @prop {String} pretty The same as value but in a prettier form | ||
*/ | ||
@@ -200,2 +204,16 @@ const axios = require('axios') | ||
} | ||
/** | ||
* | ||
* @param {String} from The currency type to convert from | ||
* @param {String} to The currency type to convert to | ||
* @param {Number} value The currency amount to convert | ||
* @returns {Promise<convertCurrencyResponse>} converted currency | ||
*/ | ||
async convertCurrency(from,to,value){ | ||
if(!from) throw new Error("[Ksoft API] Please define a currency type to convert from") | ||
if(!to) throw new Error("[Ksoft API] Please define a currency type to convert to") | ||
if(!value) throw new Error("[Ksoft API] Please define an amount to convert") | ||
const { data } = await this.http.get(`/kumo/currency?from=${from}&to=${to}&value=${value}`) | ||
return data | ||
} | ||
@@ -202,0 +220,0 @@ } |
@@ -11,2 +11,3 @@ /** | ||
* @prop {String} search_str Full title | ||
* @prop {String} album_art Url to the album art | ||
* @prop {String} id The id of the song | ||
@@ -55,2 +56,7 @@ * @prop {Number} search_score How sure the api is that it was correct | ||
* @prop {String} lyrics The lyrics for the song | ||
* | ||
* @typedef {Object} searchOptions | ||
* @prop {Boolean} textOnly Default: false, if set to 'true' then it only searches inside the lyrics. | ||
* @prop {Number} limit Default: 10, how many results should the endpoint return. | ||
* @prop {Boolean} cleanUp Whether or not to clean up the search query (good for youtube title searches) | ||
*/ | ||
@@ -69,12 +75,18 @@ const axios = require('axios') | ||
* @param {String} q The search query for lyrics | ||
* @param {Boolean} textOnly Default: false, if set to 'true' then it only searches inside the lyrics. | ||
* @param {Number} limit Default: 10, how many results should the endpoint return. | ||
* @param {searchOptions} options The options for lyrics.search | ||
* @returns {Promise<searchResponse>} information about the search query and songs | ||
*/ | ||
async search(q, {textOnly,limit}){ | ||
async search(q, options){ | ||
if(!q) throw new Error("[Ksoft API] Please define a search query") | ||
const params = { q }; | ||
if (textOnly) params.text_only = textOnly; | ||
if (limit) params.limit = limit | ||
const { data } = await this.http.get(`/lyrics/search?${require('querystring').stringify(params)}`) | ||
const params = {}; | ||
const query = q | ||
if(!options) { | ||
const { data } = await this.http.get(`/lyrics/search?q="${query}"`) | ||
return data | ||
} | ||
if (options.textOnly) params.text_only = options.textOnly; | ||
if (options.limit) params.limit = options.limit | ||
if(options.cleanUp) params.clean_up = options.cleanUp | ||
console.log(`/lyrics/search?q="${query}"${require('querystring').stringify(params)}`) | ||
const { data } = await this.http.get(`/lyrics/search?q="${query}"&${require('querystring').stringify(params)}`) | ||
return data | ||
@@ -102,3 +114,3 @@ } | ||
* @param {Number} id The track id that you want to search | ||
* @returns {getTrackByIdResults} Information about the track | ||
* @returns {Promise<getTrackByIdResults>} Information about the track | ||
*/ | ||
@@ -105,0 +117,0 @@ async getTrackById(id){ |
{ | ||
"name": "ksoft.js", | ||
"version": "1.0.3", | ||
"version": "1.0.7", | ||
"description": "Official API Wrapper for KSoft.Si API, written in Node.js", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "nodemon -q ./testing/index.js" | ||
"test": "nodemon -q ./testing/test.js" | ||
}, | ||
@@ -9,0 +9,0 @@ "repository": { |
77039
765