Kiita
Yet Another Qiita API Wrapper.
Installation
Add this line to your application's Gemfile:
gem 'kiita'
And then execute:
$ bundle
Or install it yourself as:
$ gem install kiita
Usage
Public APIs
See rate_limit
rate = Kiita::API.rate_limit
rate["remaning"] # => 148
rate["limit"] # => 150
Get an authentication token
auth = Kiita::API.authenticate("user", "password")
auth["url_name"] # => "user"
auth["token"] # => "a875scr65rc86a5s??"
Get a user's information
user = Kiita::API.user("yuki24")
user.class # => Kiita:;User
user.name # => "Yuki Nishijima"
user.location # => "Tokyo, Japan"
user.description # => "I'm a guy."
Get a user's posts
posts = Kiita::API.user("yuki24").posts
post = posts.first
post.class # => Kiita::Post
post.title # => "I'm a title!"
post.body # => "I'm a body!"
APIs that require authentication
First create an object with the token like this:
user = Kiita::API.new(token: "a875scr65rc86a5s")
then you can do the followings.
Get my information
user.me # => your information
Get your stocks
user.stocks # collection of the posts that you stocked before.
Stock a post
user.stock!("e6654a3b258b7c6b7d1") # => true if success
Unstock a post
user.unstock!("e6654a3b258b7c6b7d1") # => true if success
Configuration
Kiita currently doesn't allow to configure anything. But in the near future, it will support some confgurations like timeout and keep alive.
Support
- Ruby 1.9.2, 1.9.3
Note that Ruby 1.8.7 is NOT supported.
TODO
- Implementation of the APIs that use POST, PUT or DELETE
- Writing up rdoc as well as this README
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright
Copyright (c) 2012 Yuki Nishijima. See LICENSE.md for further details.