Class: Cellular::SMS

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

Overview

Represents an SMS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SMS

Returns a new instance of SMS.



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

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

#delivery_messageObject

Returns the value of attribute delivery_message.



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

def delivery_message
  @delivery_message
end

#delivery_statusObject

Returns the value of attribute delivery_status.



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

def delivery_status
  @delivery_status
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



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

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

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



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

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

#delivered?Boolean

Returns:



42
43
44
# File 'lib/cellular/models/sms.rb', line 42

def delivered?
  @delivered
end

#receive(_options = {}) ⇒ Object

Raises:



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

def receive(_options = {})
  raise NotImplementedError
end

#save(_options = {}) ⇒ Object

Raises:



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

def save(_options = {})
  raise NotImplementedError
end