Class: BrickFTP::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/brick_ftp/client.rb

Overview

To delegate commands.

Examples:

Call RESTfulAPI::ListUser#call

BrickFTP::Client.new.list_users

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url: nil, subdomain: nil, api_key: nil) ⇒ Client

Returns a new instance of Client.

Parameters:

  • base_url (String) (defaults to: nil)
  • subdomain (String) (defaults to: nil)

    (deprecated)

  • api_key (String) (defaults to: nil)


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/brick_ftp/client.rb', line 18

def initialize(base_url: nil, subdomain: nil, api_key: nil)
  if subdomain
    warn('DEPRECATION WARNING: The argument `subdomain:` will be deprecated in a future version.' \
         ' Please use `base_url:` instead.')
  end

  @subdomain = subdomain || ENV['BRICK_FTP_SUBDOMAIN']
  @base_url = base_url || ENV['BRICK_FTP_BASE_URL']
  @api_key = api_key || ENV['BRICK_FTP_API_KEY']
  @api_client = BrickFTP::RESTfulAPI::Client.new(@base_url || @subdomain, @api_key)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)



53
54
55
56
57
58
59
60
# File 'lib/brick_ftp/client.rb', line 53

def method_missing(name, *args)
  klass = command_class(name)
  if klass
    dispatch_command(klass, *args)
  else
    super
  end
end

Instance Attribute Details

#api_clientObject (readonly)

Returns the value of attribute api_client.



13
14
15
# File 'lib/brick_ftp/client.rb', line 13

def api_client
  @api_client
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



13
14
15
# File 'lib/brick_ftp/client.rb', line 13

def api_key
  @api_key
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



13
14
15
# File 'lib/brick_ftp/client.rb', line 13

def base_url
  @base_url
end

Instance Method Details

#subdomainObject



30
31
32
33
# File 'lib/brick_ftp/client.rb', line 30

def subdomain
  warn("DEPRECATION WARNING: #{self.class.name}##{__method__} will be deprecated in a future version.")
  @subdomain
end