Class: Cellular::SMS

Inherits:
Object
  • Object
show all
Defined in:
lib/cellular/models/sms.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SMS

Returns a new instance of SMS.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cellular/models/sms.rb', line 8

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

  @delivered = false
end

Instance Attribute Details

#country_codeObject

Returns the value of attribute country_code.



6
7
8
# File 'lib/cellular/models/sms.rb', line 6

def country_code
  @country_code
end

#messageObject

Returns the value of attribute message.



6
7
8
# File 'lib/cellular/models/sms.rb', line 6

def message
  @message
end

#priceObject

Returns the value of attribute price.



6
7
8
# File 'lib/cellular/models/sms.rb', line 6

def price
  @price
end

#recipientObject

Returns the value of attribute recipient.



6
7
8
# File 'lib/cellular/models/sms.rb', line 6

def recipient
  @recipient
end

#recipientsObject

Returns the value of attribute recipients.



7
8
9
# File 'lib/cellular/models/sms.rb', line 7

def recipients
  @recipients
end

#senderObject

Returns the value of attribute sender.



6
7
8
# File 'lib/cellular/models/sms.rb', line 6

def sender
  @sender
end

Instance Method Details

#deliverObject



21
22
23
24
# File 'lib/cellular/models/sms.rb', line 21

def deliver
  @delivery_status, @delivery_message = @backend.deliver options
  @delivered = true
end

#deliver_async(delivery_options = {}) ⇒ Object Also known as: deliver_later



26
27
28
# File 'lib/cellular/models/sms.rb', line 26

def deliver_async(delivery_options = {})
  Cellular::Jobs::AsyncMessenger.set(delivery_options).perform_later(options)
end

#delivered?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/cellular/models/sms.rb', line 39

def delivered?
  @delivered
end

#receive(options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/cellular/models/sms.rb', line 35

def receive(options = {})
  raise NotImplementedError
end

#save(options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/cellular/models/sms.rb', line 31

def save(options = {})
  raise NotImplementedError
end