class Smartfocus4rails::Message

Constants

LANG_MAPPER

See emv official doc

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
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
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