module Netfira::WebConnect::Model::Record::Sendable

Constants

AMQP_MESSAGE_TTL
DELIVERY_STATUSES

Public Instance Methods

send!() click to toggle source
# File lib/netfira/web_connect/model/record/sendable.rb, line 22
def send!
  sent!
  save!
  send_notifications!
  self
end

Private Instance Methods

send_amqp_notification!() click to toggle source
# File lib/netfira/web_connect/model/record/sendable.rb, line 54
def send_amqp_notification!
  shop.amqp_publish '', type: 'fetch', expiration: AMQP_MESSAGE_TTL
end
send_http_notification!() click to toggle source
# File lib/netfira/web_connect/model/record/sendable.rb, line 36
def send_http_notification!
  case Netfira::WebConnect.http_notifications
    when :sync then send_http_notification_now!
    when :async then Thread.new { send_http_notification_now! }
    else return
  end
end
send_http_notification_now!() click to toggle source
# File lib/netfira/web_connect/model/record/sendable.rb, line 44
def send_http_notification_now!
  uri_string = shop.settings['notify']
  if uri_string && !uri_string.empty?
    uri = URI(uri_string)
    Net::HTTP.get_response uri if %w[http https].include? uri.scheme
  end
end
send_notifications!() click to toggle source
# File lib/netfira/web_connect/model/record/sendable.rb, line 31
def send_notifications!
  send_http_notification!
  send_amqp_notification!
end