Module: Traction

Defined in:
lib/traction.rb,
lib/traction/version.rb,
lib/traction/web_connection.rb

Overview

The Traction module houses methods to interact with the Traction API.

Defined Under Namespace

Classes: WebConnection

Constant Summary collapse

VERSION =
"0.1.1"
DATE =
"2016-05-02"

Class Method Summary collapse

Class Method Details

.configure(password, web_connection_paths = {}) ⇒ Object

Configure Traction with your API password and an object containing keys that become namespaces and paths associated with a “web connection” available to you in your Traction account. These paths are found in “API Information” in the Traction Account Dashboard, for a function within a given campaign.

An ArgumentError is raised if you attempt to create a web connection name using a reserved word.

The below example generates the namespaces Traction.competition and Traction.registration for functions available in the traction dashboard. The methods available to these namespaces will depend on the functions that were created in the traction dashboard.

Examples:

Traction.configure("<your_api_password>", {competition:  "<web_connection_path>",
                                           registration: "<web_connection_path>",
                                           triggered:    "<web_connection_path>"}

Parameters:

  • password (String)

    Your API password. You might want to keep this a secret.

  • web_connection_paths (Hash) (defaults to: {})

    The namespaces and paths for each “function” eg. “/wkf/81h2ehc781hjd”



24
25
26
27
28
29
# File 'lib/traction.rb', line 24

def self.configure(password, web_connection_paths={})
  web_connection_paths.each do |name, path|
    raise ArgumentError, "!ERROR: Unable to define a web_connection_paths path with name: #{name} as this is a reserved name." if self.class.respond_to?(name)
    self.class.send(:define_method, name, -> { WebConnection.new(path, password) })
  end
end