Refresh

This website rubydoc.info/gems/freee-api/Freee/Api/Sections is currently offline. Cloudflare's Always Online™ shows a snapshot of this web page from the Internet Archive's Wayback Machine. To check for the live version, click Refresh.

Class: Freee::Api::Sections

Inherits:
Object
  • Object
show all
Defined in:
lib/freee/sections/client.rb

Constant Summary collapse

PATH =

部門取得用PATH

'/api/1/sections'

Instance Method Summary collapse

Constructor Details

#initializeSections

A new instance of HTTP Client.


11
12
13
14
15
16
17
# 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

Instance Method Details

#get_sections(access_token, params) ⇒ Hash

Parameters:

  • access_token (String)

    アクセストークン

  • params (Hash)

    新規作成用の取引先パラメータ

Returns:

  • (Hash)

    GETレスポンスの結果


24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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