Module: ActionKitApi

Defined in:
lib/action_kit_api/connection.rb,
lib/action_kit_api.rb,
lib/action_kit_api/page.rb,
lib/action_kit_api/user.rb,
lib/action_kit_api/event.rb,
lib/action_kit_api/action.rb,
lib/action_kit_api/version.rb,
lib/action_kit_api/data_model.rb,
lib/action_kit_api/searchable.rb,
lib/action_kit_api/event_campaign.rb,
lib/action_kit_api/page_types/signup.rb,
lib/action_kit_api/page_types/petition.rb,
lib/action_kit_api/page_types/unsubscribe.rb,
lib/action_kit_api/page_types/event_create.rb,
lib/action_kit_api/page_types/event_signup.rb

Overview

This is the connection information for the ActionKit API which is used throughout the rest of the Gem (a connection being required for … well every operation … this is a remote API gem :)

Defined Under Namespace

Modules: Searchable Classes: Action, ApiDataModel, Connection, Event, EventCampaign, EventCreatePage, EventSignupPage, MissingRequiredAttributeException, Page, PetitionPage, SignupPage, UnsubscribePage, User

Constant Summary collapse

VERSION =
"0.3.12"
@@connection =
nil

Class Method Summary collapse

Class Method Details

.act(page, user, args = {}) ⇒ Object

Takes a page object and a user object and a hash of any additional attributes and records the action. Will return a Action object with status information and unique identifiers



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/action_kit_api.rb', line 28

def self.act(page, user, args = {})
  return false unless page.valid? and user.valid?

  # Ensure we have an ActionKit ID before performing the action
  user.save if user.akid.nil?

  # Include the supplied arguments overiding akid and page name if they
  # were supplied with those in the page and user
  act_attrs = args.update({
    "page" => page.name,
    "akid" => user.akid,
  })

  response = @@connection.call('act', act_attrs)

  ActionKitApi::Action.new(response)
end

.connect(username, password, hostname) ⇒ Object

Takes username, password, and hostname. This is simply a wrapper to ActionKitAPi::Connection.connect to make the gem a bit easier to use



48
49
50
# File 'lib/action_kit_api.rb', line 48

def self.connect(username, password, hostname)
  @@connection = ActionKitApi::Connection.new(username, password, hostname)
end

.connectionObject



52
53
54
# File 'lib/action_kit_api.rb', line 52

def self.connection
  @@connection
end