class Qiitan::Client
ToDo 増えすぎたメソッドはModuleで分割する予定
Attributes
token[R]
Public Class Methods
new(account)
click to toggle source
Args¶ ↑
url_name passwordをキーにしたハッシュを指定する
Raise¶ ↑
RuntimeError
# File lib/qiitan.rb, line 57 def initialize(account) url = "#{API_BASE_URL}auth" res = Qiitan::HTTP.request(url, :post, true) do |req| req.set_form_data account end hashed = JSON.parse res.body raise 'auth error. check youre username and password' if hashed.key? 'error' @token = hashed['token'] end
Public Instance Methods
rate_limit()
click to toggle source
このメソッドを実行することで、APIの残りリクエスト数を取得することが出来る
# File lib/qiitan.rb, line 72 def rate_limit url = "#{API_BASE_URL}rate_limit?token=#{@token}" res = Qiitan::HTTP.request(url, :get, true) JSON.parse res.body end