Class: ActionKitApi::Action
- Inherits:
-
ApiDataModel
- Object
- ApiDataModel
- ActionKitApi::Action
- Includes:
- Searchable
- Defined in:
- lib/action_kit_api/action.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Other/Active.
-
#created_user ⇒ Object
Other/Active.
-
#custom_fields ⇒ Object
Other/Active.
-
#id ⇒ Object
Required.
-
#link ⇒ Object
Other/Active.
-
#mailing ⇒ Object
Other/Active.
-
#opq_id ⇒ Object
Other/Active.
-
#page ⇒ Object
Required.
-
#referring_mailing ⇒ Object
Other/Active.
-
#referring_user ⇒ Object
Other/Active.
-
#source ⇒ Object
Other/Active.
-
#status ⇒ Object
Other/Active.
-
#subscribed_user ⇒ Object
Other/Active.
-
#taf_emails_sent ⇒ Object
Other/Active.
-
#updated_at ⇒ Object
Other/Active.
-
#user ⇒ Object
Required.
Instance Method Summary collapse
-
#act(page, user, args = {}) ⇒ Object
Takes a page object and a user object and a hash of any additional attributes and records the action.
-
#initialize(*args) ⇒ Action
constructor
A new instance of Action.
Methods included from Searchable
Methods inherited from ApiDataModel
#save, #to_hash, #update, #valid?
Constructor Details
#initialize(*args) ⇒ Action
Returns a new instance of Action.
15 16 17 18 |
# File 'lib/action_kit_api/action.rb', line 15 def initialize(*args) @required_attrs = [:page, :user] super end |
Instance Attribute Details
#created_at ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def created_at @created_at end |
#created_user ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def created_user @created_user end |
#custom_fields ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def custom_fields @custom_fields end |
#id ⇒ Object
Required
8 9 10 |
# File 'lib/action_kit_api/action.rb', line 8 def id @id end |
#link ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def link @link end |
#mailing ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def mailing @mailing end |
#opq_id ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def opq_id @opq_id end |
#page ⇒ Object
Required
8 9 10 |
# File 'lib/action_kit_api/action.rb', line 8 def page @page end |
#referring_mailing ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def referring_mailing @referring_mailing end |
#referring_user ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def referring_user @referring_user end |
#source ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def source @source end |
#status ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def status @status end |
#subscribed_user ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def subscribed_user @subscribed_user end |
#taf_emails_sent ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def taf_emails_sent @taf_emails_sent end |
#updated_at ⇒ Object
Other/Active
11 12 13 |
# File 'lib/action_kit_api/action.rb', line 11 def updated_at @updated_at end |
#user ⇒ Object
Required
8 9 10 |
# File 'lib/action_kit_api/action.rb', line 8 def user @user end |
Instance 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
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/action_kit_api/action.rb', line 23 def 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 = ActionKitApi::Connection.call('act', act_attrs) self.new(response) end |