Class: Xlogin::APIClient
- Inherits:
-
Object
- Object
- Xlogin::APIClient
- Defined in:
- lib/xlogin/apiclient.rb,
lib/xlogin/apiclient/cli.rb,
lib/xlogin/apiclient/version.rb
Defined Under Namespace
Constant Summary collapse
- DEFAULT_TIMEOUT =
60- VERSION =
"0.2.6"
Class Attribute Summary collapse
-
.base_url ⇒ Object
Returns the value of attribute base_url.
-
.timeout ⇒ Object
Returns the value of attribute timeout.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #cmd(args, &block) ⇒ Object
-
#initialize(base_url: self.class.base_url, **args) ⇒ APIClient
constructor
A new instance of APIClient.
Constructor Details
#initialize(base_url: self.class.base_url, **args) ⇒ APIClient
Returns a new instance of APIClient.
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_url ⇒ Object
Returns the value of attribute base_url.
16 17 18 |
# File 'lib/xlogin/apiclient.rb', line 16 def base_url @base_url end |
.timeout ⇒ Object
Returns the value of attribute timeout.
17 18 19 |
# File 'lib/xlogin/apiclient.rb', line 17 def timeout @timeout end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
20 21 22 |
# File 'lib/xlogin/apiclient.rb', line 20 def args @args end |
#type ⇒ Object (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 |