Class: Freee::Base

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

Constant Summary collapse

@@client_id =
nil
@@secret_key =
nil
@@token =
nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



45
# File 'lib/freee/base.rb', line 45

def initialize; end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



31
32
33
# File 'lib/freee/base.rb', line 31

def client
  @client
end

Class Method Details

.config(client_id, secret_key, token) ⇒ Object



39
40
41
42
43
# File 'lib/freee/base.rb', line 39

def self.config(client_id, secret_key, token)
  @@client_id = client_id.to_s
  @@secret_key = secret_key.to_s
  @@token = token.to_s
end

.set_envObject



33
34
35
36
37
# File 'lib/freee/base.rb', line 33

def self.set_env
  @@client_id = ENV["FREEE_CLIENT_ID"]
  @@secret_key = ENV["FREEE_SECRET_KEY"]
  @@token = ENV["FREEE_APPLICATION_TOKEN"]
end

Instance Method Details

#get(path, type = nil) ⇒ Object



60
61
62
63
# File 'lib/freee/base.rb', line 60

def get(path, type=nil)
  response = @client.get(path).response.env[:body]
  return Freee::Response::Type.convert(response, type)
end

#post(path, type = nil, **kwargs) ⇒ Object



65
66
67
68
# File 'lib/freee/base.rb', line 65

def post(path, type=nil, **kwargs)
  response = @client.post(path, { params: kwargs }).response.env[:body]
  return Freee::Response::Type.convert(response, type)
end

#tokenObject



52
53
54
# File 'lib/freee/base.rb', line 52

def token
  @@token
end

#token=(token) ⇒ Object



56
57
58
# File 'lib/freee/base.rb', line 56

def token=(token)
  @@token = token
end