Class: Xlogin::APIClient

Inherits:
Object
  • Object
show all
Defined in:
lib/xlogin/apiclient.rb,
lib/xlogin/apiclient/cli.rb,
lib/xlogin/apiclient/version.rb

Defined Under Namespace

Classes: CLI, Error, Factory

Constant Summary collapse

DEFAULT_TIMEOUT =
60
VERSION =
"0.2.6"

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url: self.class.base_url, **args) ⇒ APIClient

Returns a new instance of APIClient.

Raises:



22
23
24
25
26
27
28
# File 'lib/xlogin/apiclient.rb', line 22

def initialize(base_url: self.class.base_url, **args)
  raise Error.new('base_url not defined') unless base_url

  @uri  = Addressable::URI.parse(base_url)
  @type = args.delete(:type)
  @args = args
end

Class Attribute Details

.base_urlObject

Returns the value of attribute base_url.



16
17
18
# File 'lib/xlogin/apiclient.rb', line 16

def base_url
  @base_url
end

.timeoutObject

Returns the value of attribute timeout.



17
18
19
# File 'lib/xlogin/apiclient.rb', line 17

def timeout
  @timeout
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



20
21
22
# File 'lib/xlogin/apiclient.rb', line 20

def args
  @args
end

#typeObject (readonly)

Returns the value of attribute type.



20
21
22
# File 'lib/xlogin/apiclient.rb', line 20

def type
  @type
end

Instance Method Details

#cmd(args, &block) ⇒ Object



30
31
32
33
# File 'lib/xlogin/apiclient.rb', line 30

def cmd(args, &block)
  params = {driver: @type, target: @args, command: args}
  request(:cmd, **params.transform_keys(&:to_sym), &block)
end