[Utopian.js] - Final Release with all features added

in #utopian-io7 years ago (edited)

New Features

<h3>What feature(s) did you add? <p dir="auto">Now the library has more functions like - <ul> <li>getPost() by username and permlink <li>getPostURL() by postID <li>getPostsByAuthor by username <li>getPostsByGithubProject <h3>How did you implement it/them? <p dir="auto">For this functions there was following lines of code- <pre><code>utopian.getPost = function (username, permlink) { return new Promise(function (resolve, reject) { $.ajax({ url: ENDPOINT_POST + '/' + username + '/' + permlink, success: function success(data) { resolve(data); }, error: function error(xhr, status, _error6) { reject(_error6); } }); }); }; utopian.getPostURL = function (postID) { return new Promise(function (resolve, reject) { $.ajax({ url: ENDPOINT_POST + '/byid/' + postID, success: function success(data) { resolve('https://utopian.io' + data.url); }, error: function error(xhr, status, _error7) { reject(_error7); } }); }); }; utopian.getPostsByAuthor = (username, options={}) => { let ENDPOINT_POSTS = ENDPOINT_POST if (options.limit > 20 || options.limit < 1) { options.limit = 20 } if (Object.keys(options).length === 0) { options.limit = 20 options.skip = 0 } options.section = 'author' options.author = username ENDPOINT_POSTS+= '?'; for(let x in options) { ENDPOINT_POSTS = `${ENDPOINT_POSTS}` + `${x}=${options[x]}&` } ENDPOINT_POSTS = ENDPOINT_POSTS.slice(0,-1) return new Promise((resolve, reject) => { $.ajax( { url: ENDPOINT_POSTS, success: function(result) { resolve(result); }, error: function(xhr, status, error) { reject(error) } }) }) } utopian.getPostsByGithubProject = (repoName, options) => { return new Promise((resolve, reject) => { return getGithubRepoIdByRepoName(repoName) .then(projectId => { return utopian.getPosts(Object.assign({ section: 'project', sortBy: 'created', platform: 'github', projectId, type: 'all' }, options || {})).then(resolve).catch(reject) }).catch(reject) }) } <h3>Roadmap <p dir="auto">This would be its alpha release and maybe more features would be added if there are more endpoints added to the API or requested by the users. <ul> <li>How to contribute?<br /> You may contribute to the repository by forking it and making a PR.<br /> PR's are always welcome :) <p dir="auto">Thanks for reading. <p dir="auto"><br /><hr /><em>Posted on <a href="https://utopian.io/utopian-io/@ms10398/utopian-js-final-release-with-all-features-added" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Utopian.io - Rewarding Open Source Contributors<hr /><p>
Sort:  

Are you flash? :D

Hey @wehmoen, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

Hey @ms10398 I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x