Class: Voltron::Notification::SmsNotification

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/voltron/notification/sms_notification.rb

Defined Under Namespace

Classes: Attachment

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#createdObject

Returns the value of attribute created.



29
30
31
# File 'app/models/voltron/notification/sms_notification.rb', line 29

def created
  @created
end

Instance Method Details

#attach(*urls) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'app/models/voltron/notification/sms_notification.rb', line 51

def attach(*urls)
  urls.flatten.each do |url|
    if url.starts_with? 'http'
      attachments.build attachment: url
    else
      attachments.build attachment: Voltron.config.base_url + ActionController::Base.helpers.asset_url(url)
    end
  end
end

#deliver_later(options = {}) ⇒ Object

Establish that the job should be enqueued, and set the options



46
47
48
49
# File 'app/models/voltron/notification/sms_notification.rb', line 46

def deliver_later(options={})
  @job_options = options
  @job_method = :perform_later
end

#deliver_nowObject

Establish that we will perform the job immediately. Will cause send_now to be called instead when saved



40
41
42
43
# File 'app/models/voltron/notification/sms_notification.rb', line 40

def deliver_now
  @job_options = {}
  @job_method = :perform_now
end

#requestObject



31
32
33
# File 'app/models/voltron/notification/sms_notification.rb', line 31

def request
  Voltron::Notification.format_output_of(request_json)
end

#responseObject



35
36
37
# File 'app/models/voltron/notification/sms_notification.rb', line 35

def response
  Voltron::Notification.format_output_of(response_json)
end

#valid_phone?Boolean

Returns:

  • (Boolean)


61
62
63
64
65
66
67
68
69
# File 'app/models/voltron/notification/sms_notification.rb', line 61

def valid_phone?
  begin
    to_formatted
    true
  rescue ::Twilio::REST::RequestError => e
    Voltron.log e.message, 'Notify', Voltron::Notify::LOG_COLOR
    false
  end
end