Module: ActiveCampaign::API::ClassMethods

Defined in:
lib/active_campaign/api.rb

Overview

Extends the base class when ActiveCampaign::API is included

Author:

Instance Method Summary collapse

Instance Method Details

#endpoint(endpoint) ⇒ void

This method returns an undefined value.

Utility method to avoid some duplication for requiring files and including API modules

Parameters:

  • endpoint (Symbol)

    an endpoint to include example: :users



40
41
42
43
44
45
46
# File 'lib/active_campaign/api.rb', line 40

def endpoint(endpoint)
  require "active_campaign/api/#{endpoint}"

  class_eval { include API.const_get(endpoint.to_s.camelize) }
rescue LoadError, NameError
  raise DependencyMissing, endpoint
end

#endpoints(*endpoints) ⇒ void

This method returns an undefined value.

Utility method to avoid some duplication for requiring files and including

Parameters:

  • endpoints (Array<Symbol>)

    an array of endpoints to include :users



27
28
29
30
31
# File 'lib/active_campaign/api.rb', line 27

def endpoints(*endpoints)
  endpoints.each do |endpoint|
    endpoint(endpoint)
  end
end

#loggerLogger

Memoized logger for convenience

Returns:

  • (Logger)

    any object that responds to :debug, :info, :warn, :error and :fatal



54
55
56
# File 'lib/active_campaign/api.rb', line 54

def logger
  @logger ||= ActiveCampaign.logger
end