Sha256: fc6d59b07f120a1b0c54e5c6499200c386d449cbc780efe82df9f57ae2642567

Contents?: true

Size: 392 Bytes

Versions: 8

Compression:

Stored size: 392 Bytes

Contents

# frozen_string_literal: true

module Gupshup
  class Response
    attr_accessor :status_code, :body, :headers

    def initialize(status_code, body, headers: nil)
      @status_code = status_code
      body = '{}' if !body || body.empty?
      @body = JSON.parse(body)
      @headers = !headers ? {} : headers.to_hash
    end

    def to_s
      "[#{status_code}] #{body}"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gupshup-rb-0.2.1 lib/gupshup-rb/framework/response.rb
gupshup-rb-0.2.0 lib/gupshup-rb/framework/response.rb
gupshup-rb-0.1.9 lib/gupshup-rb/framework/response.rb
gupshup-rb-0.1.8.4 lib/gupshup-rb/framework/response.rb
gupshup-rb-0.1.8.3 lib/gupshup-rb/framework/response.rb
gupshup-rb-0.1.8.2 lib/gupshup-rb/framework/response.rb
gupshup-rb-0.1.8.1 lib/gupshup-rb/framework/response.rb
gupshup-rb-0.1.8 lib/gupshup-rb/framework/response.rb