Class: EFax::OutboundStatusResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/efax/outbound.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ OutboundStatusResponse

:nodoc:



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/efax/outbound.rb', line 179

def initialize(response) #:nodoc:
  if response.is_a? Net::HTTPOK
    doc = Hpricot(response.body)
    @message = doc.at(:message).innerText
    @classification = doc.at(:classification).innerText.delete('"')
    @outcome = doc.at(:outcome).innerText.delete('"')
    if !sent_yet?(classification, outcome) || busy_signal?(classification)
      @status_code = QueryStatus::PENDING
    elsif @classification == "Success" && @outcome == "Success"
      @status_code = QueryStatus::SENT
    else
      @status_code = QueryStatus::FAILURE
    end
  else
    @status_code = QueryStatus::HTTP_FAILURE
    @message = "HTTP request failed (#{response.code})"
  end
end

Instance Attribute Details

#classificationObject (readonly)

Returns the value of attribute classification.



176
177
178
# File 'lib/efax/outbound.rb', line 176

def classification
  @classification
end

#messageObject (readonly)

Returns the value of attribute message.



175
176
177
# File 'lib/efax/outbound.rb', line 175

def message
  @message
end

#outcomeObject (readonly)

Returns the value of attribute outcome.



177
178
179
# File 'lib/efax/outbound.rb', line 177

def outcome
  @outcome
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



174
175
176
# File 'lib/efax/outbound.rb', line 174

def status_code
  @status_code
end

Instance Method Details

#busy_signal?(classification) ⇒ Boolean

Returns:

  • (Boolean)


198
199
200
# File 'lib/efax/outbound.rb', line 198

def busy_signal?(classification)
  classification == "Busy"
end

#sent_yet?(classification, outcome) ⇒ Boolean

Returns:

  • (Boolean)


202
203
204
# File 'lib/efax/outbound.rb', line 202

def sent_yet?(classification, outcome)
  !classification.empty? || !outcome.empty?
end