Class: Skuby::SMSResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/skuby/sms_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, text, recipients) ⇒ SMSResponse

Returns a new instance of SMSResponse.



5
6
7
8
9
# File 'lib/skuby/sms_response.rb', line 5

def initialize(response, text, recipients)
  @response = CGI.parse(response)
  @text = text
  @recipients = Array(recipients)
end

Instance Attribute Details

#recipientsObject (readonly)

Returns the value of attribute recipients.



3
4
5
# File 'lib/skuby/sms_response.rb', line 3

def recipients
  @recipients
end

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/skuby/sms_response.rb', line 3

def response
  @response
end

#textObject (readonly)

Returns the value of attribute text.



3
4
5
# File 'lib/skuby/sms_response.rb', line 3

def text
  @text
end

Instance Method Details

#error_codeObject



31
32
33
# File 'lib/skuby/sms_response.rb', line 31

def error_code
  @response["code"].first.to_i
end

#error_messageObject



35
36
37
# File 'lib/skuby/sms_response.rb', line 35

def error_message
  @response["message"].first
end

#remaining_smsObject



23
24
25
# File 'lib/skuby/sms_response.rb', line 23

def remaining_sms
  @response["remaining_sms"].first.to_i
end

#sms_idObject



27
28
29
# File 'lib/skuby/sms_response.rb', line 27

def sms_id
  @response["id"].first
end

#sms_id?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/skuby/sms_response.rb', line 15

def sms_id?
  !sms_id.nil?
end

#statusObject



19
20
21
# File 'lib/skuby/sms_response.rb', line 19

def status
  @response["status"].first
end

#success?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/skuby/sms_response.rb', line 11

def success?
  status == "success"
end