lib/cellular/models/sms.rb in cellular-1.3.0 vs lib/cellular/models/sms.rb in cellular-2.0.0
- old
+ new
@@ -1,13 +1,16 @@
+require 'active_support/time'
+
module Cellular
class SMS
attr_accessor :recipient, :sender, :message, :price, :country_code
-
+ attr_accessor :recipients
def initialize(options = {})
@backend = Cellular.config.backend
+ @recipients = options[:recipients]
@recipient = options[:recipient]
@sender = options[:sender] || Cellular.config.sender
@message = options[:message]
@price = options[:price] || Cellular.config.price
@country_code = options[:country_code] || Cellular.config.country_code
@@ -18,13 +21,14 @@
def deliver
@delivery_status, @delivery_message = @backend.deliver options
@delivered = true
end
- def deliver_later
- Cellular::Jobs::AsyncMessenger.perform_async options
+ def deliver_async(delivery_options = {})
+ Cellular::Jobs::AsyncMessenger.set(delivery_options).perform_later(options)
end
+ alias_method :deliver_later, :deliver_async
def save(options = {})
raise NotImplementedError
end
@@ -33,24 +37,15 @@
end
def delivered?
@delivered
end
-
- def country
- warn "[DEPRECATION] 'country' is deprecated; use 'country_code' instead"
- @country_code
- end
- def country=(country)
- warn "[DEPRECATION] 'country' is deprecated; use 'country_code' instead"
- @country_code = country
- end
-
private
def options
{
+ recipients: @recipients,
recipient: @recipient,
sender: @sender,
message: @message,
price: @price,
country_code: @country_code