Class: Pipedrive::Client

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

Instance Method Summary collapse

Methods inherited from Base

#[], #all, #authenticate, #base_uri, #get, #initialize, #metric_key, #prepare_options, #protocol, #resource, #resource_path

Constructor Details

This class inherits a constructor from Pipedrive::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, options, &block) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/pipedrive/client.rb', line 29

def method_missing(name, options, &block)
  begin
    resource(name, options)
  rescue NameError
    # Since we're silently loading a Resource Class
    # we transform this into a NoMethodError to
    # mask that. Not sure if this is the best idea ever,
    # but I like it for now.
    raise NoMethodError, "undefined method '#{name}' for #{self}"
  end
end

Instance Method Details

#metricsObject



10
11
12
13
14
15
16
17
18
# File 'lib/pipedrive/client.rb', line 10

def metrics
  metrics = {}

  %i{activities deals organizations persons}.each do |source|
    metrics[source] = send(source).metrics
  end

  metrics
end

#validate_authorizationObject



20
21
22
23
24
25
26
27
# File 'lib/pipedrive/client.rb', line 20

def validate_authorization
  begin
    users.metrics
    true
  rescue AuthenticationError
    false
  end
end