Sha256: d26249a02ac59525b959943b3379e87be6398e1f978cd6544e3c9d5ec99bd4fc

Contents?: true

Size: 507 Bytes

Versions: 5

Compression:

Stored size: 507 Bytes

Contents

require 'json'

module CRP
  class ReviewResponse
    SUCCESS_STATUS_CODE = 200
    EMPTY_JSON          = "{}"

    def initialize(response)
      @response = response
    end

    def successful?
      @response.code.to_i == SUCCESS_STATUS_CODE
    end

    def raw_review
      body = successful? ? @response.body : EMPTY_JSON
      JSON.parse(body)
    end

    def internal_id
      raw_review.first["internalId"].to_s
    end

    def external_id
      raw_review.first["externalId"]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
crp-0.0.6 lib/crp/review_response.rb
crp-0.0.5 lib/crp/review_response.rb
crp-0.0.4 lib/crp/review_response.rb
crp-0.0.3 lib/crp/review_response.rb
crp-0.0.2 lib/crp/review_response.rb