Class: FreshdeskApiclient::REST::Client

Inherits:
Object
  • Object
show all
Includes:
Utils::Loggeable
Defined in:
lib/freshdesk_apiclient/rest/client.rb

Constant Summary collapse

RESOURCES =
%i(tickets).freeze

Instance Method Summary collapse

Methods included from Utils::Loggeable

#logger, #standard_out_logger

Constructor Details

#initialize(domain: FreshdeskApiclient.domain, username_or_api_key: FreshdeskApiclient.username_or_api_key, password: FreshdeskApiclient.password, logger: FreshdeskApiclient.logger) ⇒ Client

Returns a new instance of Client.

Parameters:

  • domain (String) (defaults to: FreshdeskApiclient.domain)
  • username_or_api_key (String) (defaults to: FreshdeskApiclient.username_or_api_key)
  • password (String) (defaults to: FreshdeskApiclient.password)
  • logger (Logger) (defaults to: FreshdeskApiclient.logger)


17
18
19
20
21
22
23
# File 'lib/freshdesk_apiclient/rest/client.rb', line 17

def initialize(domain: FreshdeskApiclient.domain,
               username_or_api_key: FreshdeskApiclient.username_or_api_key,
               password: FreshdeskApiclient.password, logger: FreshdeskApiclient.logger)
  @base_url = "https://#{domain}.freshdesk.com/api/v2/"
  @credentials = {user: username_or_api_key, password: password}
  @logger = logger
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *arguments, &block) ⇒ Object

obj.method_missing(symbol [, *args] ) -> result



26
27
28
# File 'lib/freshdesk_apiclient/rest/client.rb', line 26

def method_missing(symbol, *arguments, &block)
  RESOURCES.include?(symbol) ? instance_variable(symbol) : super
end

Instance Method Details

#respond_to_missing?(method) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/freshdesk_apiclient/rest/client.rb', line 30

def respond_to_missing?(method, *)
  RESOURCES.include?(method) ? true : super
end