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