lib/cellular/models/sms.rb in cellular-1.2.0 vs lib/cellular/models/sms.rb in cellular-1.3.0
- old
+ new
@@ -1,43 +1,62 @@
module Cellular
class SMS
- attr_accessor :recipient, :sender, :message, :price, :country
+ attr_accessor :recipient, :sender, :message, :price, :country_code
def initialize(options = {})
@backend = Cellular.config.backend
@recipient = options[:recipient]
@sender = options[:sender] || Cellular.config.sender
@message = options[:message]
@price = options[:price] || Cellular.config.price
- @country = options[:country] || Cellular.config.country_code
+ @country_code = options[:country_code] || Cellular.config.country_code
@delivered = false
end
def deliver
- @delivery_status, @delivery_message = @backend.deliver(
- recipient: @recipient,
- sender: @sender,
- price: @price,
- country: @country,
- message: @message
- )
-
+ @delivery_status, @delivery_message = @backend.deliver options
@delivered = true
end
+ def deliver_later
+ Cellular::Jobs::AsyncMessenger.perform_async options
+ end
+
def save(options = {})
raise NotImplementedError
end
def receive(options = {})
raise NotImplementedError
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
+ {
+ recipient: @recipient,
+ sender: @sender,
+ message: @message,
+ price: @price,
+ country_code: @country_code
+ }
end
end
end