Class: Tripletexer::APIClient
- Inherits:
-
Object
- Object
- Tripletexer::APIClient
- Defined in:
- lib/tripletexer/api_client.rb
Constant Summary collapse
- ENDPOINT =
'https://tripletex.no/'
Instance Attribute Summary collapse
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#session_token ⇒ Object
Returns the value of attribute session_token.
Instance Method Summary collapse
- #connection ⇒ Object
- #delete(path, *args, &block) ⇒ Object
- #get(path, *args, &block) ⇒ Object
-
#initialize(object_class: Hash, proxy: nil, debug: false) ⇒ APIClient
constructor
A new instance of APIClient.
- #post(path, *args, &block) ⇒ Object
- #put(path, *args, &block) ⇒ Object
- #reset_connection ⇒ Object
Constructor Details
#initialize(object_class: Hash, proxy: nil, debug: false) ⇒ APIClient
Returns a new instance of APIClient.
14 15 16 17 18 |
# File 'lib/tripletexer/api_client.rb', line 14 def initialize(object_class: Hash, proxy: nil, debug: false) @object_class = object_class @proxy = proxy @debug = debug end |
Instance Attribute Details
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
12 13 14 |
# File 'lib/tripletexer/api_client.rb', line 12 def debug @debug end |
#session_token ⇒ Object
Returns the value of attribute session_token.
12 13 14 |
# File 'lib/tripletexer/api_client.rb', line 12 def session_token @session_token end |
Instance Method Details
#connection ⇒ Object
20 21 22 23 |
# File 'lib/tripletexer/api_client.rb', line 20 def connection return @connection if session_token && @connection @connection = init_connection end |
#delete(path, *args, &block) ⇒ Object
46 47 48 |
# File 'lib/tripletexer/api_client.rb', line 46 def delete(path, *args, &block) call(:delete, path, *args, &block) end |
#get(path, *args, &block) ⇒ Object
34 35 36 |
# File 'lib/tripletexer/api_client.rb', line 34 def get(path, *args, &block) call(:get, path, *args, &block) end |
#post(path, *args, &block) ⇒ Object
38 39 40 |
# File 'lib/tripletexer/api_client.rb', line 38 def post(path, *args, &block) call(:post, path, *args, &block) end |
#put(path, *args, &block) ⇒ Object
42 43 44 |
# File 'lib/tripletexer/api_client.rb', line 42 def put(path, *args, &block) call(:put, path, *args, &block) end |
#reset_connection ⇒ Object
25 26 27 |
# File 'lib/tripletexer/api_client.rb', line 25 def reset_connection @session_token = @connection = nil end |