Sha256: 296598037de6f6560246aabcfaf9a8138eb51cf8beb8674edaf7c4303d64e082

Contents?: true

Size: 468 Bytes

Versions: 2

Compression:

Stored size: 468 Bytes

Contents

module CmSms
  class Response
    attr_reader :net_http_response, :body, :code
    
    def initialize(net_http_response)
      @net_http_response = net_http_response
      @body              = @net_http_response.body
      @code              = @net_http_response.code
    end
    
    def success?
      body.empty? && code.to_i == 200
    end
    
    def failure?
      !success?
    end
    
    def error
      body.sub('Error: ERROR', '').strip
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cm-sms-0.1.1 lib/cm_sms/response.rb
cm-sms-0.1.0 lib/cm_sms/response.rb