Sha256: df03c3a11b4cb50f4960368bc3fc027776869e0eb7f2357e04cf1f27a0cfce36

Contents?: true

Size: 645 Bytes

Versions: 3

Compression:

Stored size: 645 Bytes

Contents

require 'messagebird_texter/response/body'
require 'messagebird_texter/response/error'
module MessagebirdTexter
  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?
      code.to_i == 201
    end

    def failure?
      !success?
    end

    def body
      MessagebirdTexter::Response::Body.new(@body) if success?
    end

    def error
      MessagebirdTexter::Response::Error.new(@body) if failure?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
messagebird-texter-0.1.1 lib/messagebird_texter/response.rb
messagebird-texter-0.1.0 lib/messagebird_texter/response.rb
messagebird-texter-0.0.2 lib/messagebird_texter/response.rb