This is the Ruby client library that wraps the Designer News API. It assumes you have used another oAuth 2 library to obtain and manage a valid access token. It is based on the Ruby gem for the LayerVault API.
Put this in your Gemfile and smoke it:
gem 'dn'
Or install it:
$ gem install dn
Currently only Resource Owner Credentials and Client Credentials are supported.
- Please send an email to [email protected] to request your API credentials. Please include your callback URL. One day, this might be automated.
- Receive a friendly note back from the LayerVault staff with your application credentials.
- Note your
client_id
andclient_secret
. - Try the example Access Token request below.
curl -i https://api-news.layervault.com/oauth/token \
-F grant_type="password" \
-F username="<username_goes_here>" \
-F password="<password_goes_here>" \
-F client_id="<client_id_goes_here>" \
-F client_secret="<client_secret_goes_here>"
- You now have an access token. You can make API requests by calling via CURL like so:
curl -H 'Authorization: Bearer <your access token>' \
'https://api-news.layervault.com/api/v1/me'
You can initialize the client via Environment Variables or by passing configurations options into the client when you create it, like this:
@client = DesignerNews::Client.new({
access_token: 'your_access_token',
api_endpoint: 'your_api_endpoint'
})
Or you can also say:
DesignerNews.client.access_token = 'access_token'
DesignerNews.client.api_endpoint = 'api_endpoint'
# You Designer News API access token
ENV['DESIGNER_NEWS_ACCESS_TOKEN']
# The API Endpoint you wish to target calls against (defaults to https://api-news.layervault.com/api/v1/)
ENV['DESIGNER_NEWS_API_ENDPOINT']
# Defaults to Designer News Ruby Gem #{DesignerNews::VERSION}
ENV['DESIGNER_NEWS_USER_AGENT']
You should set the User agent to include your email address so that in the event your client does something wrong we can contact you.
You should instantiate a DesignerNews::Client
object and then make calls from that:
client = DesignerNews::Client.new({
access_token: 'your_access_token',
api_endpoint: 'your_api_endpoint'
})
client.story(123)
client.upvote_story(123)
And so on.
Coming soon.
#me
#story(story_id)
#stories(page_number=1)
#recent_stories(page_number=1)
#search_stories(query)
#upvote_story(story_id)
#reply_to_story(story_id, comment)
#comment(comment_id)
#upvote_comment(comment_id)
#reply_to_comment(comment_id, comment)
#motd
#upvote_motd
#downvote_motd