Class: Tripletexer::APIClient

Inherits:
Object
  • Object
show all
Defined in:
lib/tripletexer/api_client.rb

Constant Summary collapse

ENDPOINT =
'https://tripletex.no/'

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#debugObject (readonly)

Returns the value of attribute debug.



12
13
14
# File 'lib/tripletexer/api_client.rb', line 12

def debug
  @debug
end

#session_tokenObject

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

#connectionObject



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_connectionObject



25
26
27
# File 'lib/tripletexer/api_client.rb', line 25

def reset_connection
  @session_token = @connection = nil
end