class Freee::Api::Sections
Constants
- PATH
部門取得用PATH
Public Class Methods
new()
click to toggle source
A new instance of HTTP Client.
# File lib/freee/sections/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_sections(access_token, params)
click to toggle source
部門一覧の取得 developer.freee.co.jp/docs/accounting/reference#/Sections/get_api_1_sections @param access_token [String] アクセストークン @param params [Hash] 新規作成用の取引先パラメータ @return [Hash] GETレスポンスの結果
# File lib/freee/sections/client.rb, line 24 def get_sections(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 401 raise 'Unauthorized' end response end