I have added three more functions to the npm package.
utopian.getPost = (username, permlink) => {
return new Promise((resolve, reject) => {
requestURL(ENDPOINT_POSTS + '/' + username + '/' + permlink).then((data) => {
resolve(JSON.parse(data))
}).catch((err) => reject(err))
})
}
utopian.getPostURL = (postID) => {
return new Promise((resolve, reject) => {
requestURL(ENDPOINT_POSTS + '/byid/' + postID).then((data) => {
resolve('https://utopian.io' + JSON.parse(data).url)
}).catch((err) => reject(err))
})
}
utopian.getPostByAuthor = (username, options) => {
return new Promise((resolve, reject) => {
if (!options) options = {}
if (options.limit > 20 || options.limit < 1) {
options.limit = 20
}
if (options.length === 0) {
options.limit = 20
options.skip = 0
}
options.section = 'author'
options.author = username
requestURL(ENDPOINT_POSTS + '?' + encodeQueryData(options)).then((data) => {
resolve(JSON.parse(data))
}).catch((err) => reject(err))
})
}
I referred to the Utopian docs for checking out the endpoints to add these specific features. I have added relevant tests for these features. You can see the commits in the attached pull request.
Tests were written usng chaiJS and mochaJS and code qulity was checked by standard.