class PixivApi::Client
Attributes
access_token[R]
client[R]
Public Class Methods
from_account(id:, password:)
click to toggle source
For development
# File lib/pixiv_api/client.rb, line 30 def self.from_account(id:, password:) PixivApi::Authentication.new(id: id, password: password).to_client end
new(access_token:, refresh_token:, expires_at:)
click to toggle source
# File lib/pixiv_api/client.rb, line 34 def initialize(access_token:, refresh_token:, expires_at:) token_hash = { access_token: access_token, refresh_token: refresh_token, expires_at: expires_at.to_i } @client = OAuth2::Client.new(*client_configuration) do |builder| builder.request :multipart builder.request :url_encoded builder.adapter Faraday.default_adapter end @access_token = OAuth2::AccessToken.from_hash(client, token_hash) end
Public Instance Methods
refresh!()
click to toggle source
# File lib/pixiv_api/client.rb, line 49 def refresh! @access_token = @access_token.refresh! end
Private Instance Methods
client_configuration()
click to toggle source
# File lib/pixiv_api/client.rb, line 59 def client_configuration configuration = PixivApi.configuration configuration.require_keys! # 必要な設定がなされているかチェック [ configuration.client_id, configuration.client_secret, site: configuration.site, authorize_url: configuration.authorize_url, token_url: configuration.token_url ] end
unsupported!(path)
click to toggle source
# File lib/pixiv_api/client.rb, line 55 def unsupported!(path) raise PixivApi::Client::UnsupportedApiError, "route of #{path} is not supported." end