class Smartfocus4rails::Message
Constants
- LANG_MAPPER
See emv official doc
- LINK_TYPE_MAPPER
Public Class Methods
new(body = "", payload = {})
click to toggle source
Validate format of email address
# File lib/smartfocus4rails/models/message.rb, line 48 def initialize(body = "", payload = {}) self.body = body payload.each do |attr, val| send("#{attr}=", val) if attributes.has_key?(attr.to_s) end end
Public Instance Methods
create()
click to toggle source
# File lib/smartfocus4rails/models/message.rb, line 55 def create if valid? run_callbacks :create do self.id = api.post.message.create(:body => {:message => self.to_emv}).call end true else false end end
create_and_add_action_url(name, action, page_ok, message_ok, page_error, message_error)
click to toggle source
Replaces the first occurrence of &&& with [EMV LINK]ORDER[EMV /LINK] (where ORDER is the action link order number).
Parameters :
- name : The name of the URL - action : The action to perform - page_ok : The URL to call if the action was successful - message_ok : The message to display if the action was successful - page_error : The URL to call if the action was unsuccessful - message_error : The message to display if the action was unsuccessful Last 4 params is not require, but due to an API bug it must be present and must be an existing bounceback message id (eg: message with syntaxic error)
# File lib/smartfocus4rails/models/message.rb, line 105 def create_and_add_action_url(name, action, page_ok, message_ok, page_error, message_error) api.get.url.create_and_add_action_url(uri: [id, name, action, page_ok, message_ok, page_error, message_error]).call end
create_and_add_mirror_url()
click to toggle source
Replaces the first occurrence of &&& with
- EMV LINK]ORDER[EMV /LINK
-
(where ORDER is the mirror link order number).
# File lib/smartfocus4rails/models/message.rb, line 91 def create_and_add_mirror_url api.get.url.create_and_add_mirror_url(uri: [id, 'mirror_url']).call end
delete_link(link_id)
click to toggle source
This method deletes a URL. You can only delete a message's URL, if the message is not associated to a campaign. Parameter :
-
link_id : The ID of the link to delete
# File lib/smartfocus4rails/models/message.rb, line 134 def delete_link(link_id) api.get.url.delete_url(uri: [id, link_id]).call end
destroy()
click to toggle source
# File lib/smartfocus4rails/models/message.rb, line 76 def destroy run_callbacks :destroy do self.id = api.get.message.deleteMessage(:uri => [self.id]).call end true end
mirror_url_id()
click to toggle source
Deprecated
# File lib/smartfocus4rails/models/message.rb, line 84 def mirror_url_id warn "[DEPRECATION] mirror_url_id is deprecated. Use create_and_add_mirror_url instead" @mirror_url_id ||= create_and_add_mirror_url end
persisted?()
click to toggle source
# File lib/smartfocus4rails/models/message.rb, line 146 def persisted? id.present? end
track_links()
click to toggle source
# File lib/smartfocus4rails/models/message.rb, line 138 def track_links api.get.message.track_all_links(id: id).call end
untrack_links()
click to toggle source
# File lib/smartfocus4rails/models/message.rb, line 142 def untrack_links api.get.message.untrack_all_links(id: id).call end
unused_tracked_links()
click to toggle source
This method retrieves the unused tracked links It returns an array of link ids
# File lib/smartfocus4rails/models/message.rb, line 122 def unused_tracked_links result = api.get.message.get_all_unused_tracked_links(uri: [id]).call result["entities"]["id"] rescue NoMethodError [] end
update()
click to toggle source
# File lib/smartfocus4rails/models/message.rb, line 66 def update if valid? and persisted? run_callbacks :update do api.post.message.update(:body => {:message => self.to_emv}).call end else false end end