Class: AnySMS::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/any_sms/response.rb

Overview

Response object. Generated on each AnySMS.send_sms by backend implementations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, meta: nil) ⇒ Response

Returns a new instance of Response.

Parameters:

  • status (Symbol)

    Status of sms request. Anything other than :success considered as failure.

  • meta (Hash) (defaults to: nil)

    Meta information which optionally can be returned by backend.



14
15
16
17
# File 'lib/any_sms/response.rb', line 14

def initialize(status:, meta: nil)
  @status = status
  @meta = meta
end

Instance Attribute Details

#metaObject

see initialize



8
9
10
# File 'lib/any_sms/response.rb', line 8

def meta
  @meta
end

#statusObject (readonly)

see initialize



5
6
7
# File 'lib/any_sms/response.rb', line 5

def status
  @status
end

Instance Method Details

#failed?Boolean

Returns whether request has failed or not.

Returns:

  • (Boolean)

    whether request has failed or not.



25
26
27
# File 'lib/any_sms/response.rb', line 25

def failed?
  !success?
end

#success?Boolean

Returns whether request was succesful or not.

Returns:

  • (Boolean)

    whether request was succesful or not.



20
21
22
# File 'lib/any_sms/response.rb', line 20

def success?
  @status == :success
end