Class: Freee::Api::AccountItems
- Inherits:
-
Object
- Object
- Freee::Api::AccountItems
- Defined in:
- lib/freee/account_items/client.rb
Constant Summary collapse
- PATH =
勘定項目取得用PATH
'/api/1/account_items'
Instance Method Summary collapse
- #get_account_items(access_token, params) ⇒ Hash
-
#initialize ⇒ AccountItems
constructor
A new instance of HTTP Client.
Constructor Details
#initialize ⇒ AccountItems
A new instance of HTTP Client.
11 12 13 14 15 16 17 |
# 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 |
Instance Method Details
#get_account_items(access_token, params) ⇒ Hash
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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. :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 |