Class: Freee::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/freee/base.rb
Direct Known Subclasses
AccountItem, Company, Deal, Item, Partner, Response::Company, Response::Deal, Response::Item, Response::Partner, Response::Section, Response::Tag, Response::Tax, Response::User, Section, Tag, Tax, Transfer, User, WalletTxn, Walletable
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
#initialize ⇒ Base
Returns a new instance of Base.
53
|
# File 'lib/freee/base.rb', line 53
def initialize; end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
39
40
41
|
# File 'lib/freee/base.rb', line 39
def client
@client
end
|
Class Method Details
.config(client_id, secret_key, token) ⇒ Object
47
48
49
50
51
|
# File 'lib/freee/base.rb', line 47
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_env ⇒ Object
41
42
43
44
45
|
# File 'lib/freee/base.rb', line 41
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
68
69
70
71
|
# File 'lib/freee/base.rb', line 68
def get(path, type=nil)
response = @client.get(path).response.env[:body]
return Freee::Response::Type.convert(response, type)
end
|
#post(path, type = nil, params) ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/freee/base.rb', line 73
def post(path, type=nil, params)
response = @client.post(path, { body: {params: params} }).response.env[:body]
rescue
response = @client.post(path + params).response.env[:body]
ensure
return Freee::Response::Type.convert(response, type)
end
|
#token ⇒ Object
60
61
62
|
# File 'lib/freee/base.rb', line 60
def token
@@token
end
|
#token=(token) ⇒ Object
64
65
66
|
# File 'lib/freee/base.rb', line 64
def token=(token)
@@token = token
end
|