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.



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

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

  @delivered = false
end

Instance Attribute Details

#countryObject

Returns the value of attribute country.



4
5
6
# File 'lib/cellular/models/sms.rb', line 4

def country
  @country
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/cellular/models/sms.rb', line 4

def message
  @message
end

#priceObject

Returns the value of attribute price.



4
5
6
# File 'lib/cellular/models/sms.rb', line 4

def price
  @price
end

#recipientObject

Returns the value of attribute recipient.



4
5
6
# File 'lib/cellular/models/sms.rb', line 4

def recipient
  @recipient
end

#senderObject

Returns the value of attribute sender.



4
5
6
# File 'lib/cellular/models/sms.rb', line 4

def sender
  @sender
end

Instance Method Details

#deliverObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cellular/models/sms.rb', line 18

def deliver
  @delivery_status, @delivery_message = @backend.deliver(
    recipient: @recipient,
    sender: @sender,
    price: @price,
    country: @country,
    message: @message
  )

  @delivered = true
end

#delivered?Boolean

Returns:

  • (Boolean)


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

def delivered?
  @delivered
end

#receive(options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


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

def receive(options = {})
  raise NotImplementedError
end

#save(options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


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

def save(options = {})
  raise NotImplementedError
end