class Freee::Api::AccountItems
Constants
- PATH
勘定項目取得用PATH
Public Class Methods
new()
click to toggle source
A new instance of HTTP Client.
# File lib/freee/account_items/client.rb, line 11 def initialize @client = Faraday.new(url: Parameter::SITE) do |faraday| faraday.request :json faraday.response :json, content_type: /\bjson$/ faraday.adapter Faraday.default_adapter end end
Public Instance Methods
get_account_items(access_token, params)
click to toggle source
勘定項目の取得 developer.freee.co.jp/docs/accounting/reference#/Account_items/get_api_1_account_items @param access_token [String] アクセストークン @param params [Hash] 取得用のパラメータ @return [Hash] 勘定項目取得の結果
# File lib/freee/account_items/client.rb, line 24 def get_account_items(access_token, params) raise 'アクセストークンが設定されていません' if access_token.empty? raise '事業所IDが設定されていません' unless params.key?(:company_id) @client.authorization :Bearer, access_token response = @client.get do |req| req.url PATH req.body = params.to_json end case response.status when 400 raise StandardError, response.body when 401 raise 'Unauthorized' end response end