Sha256: b2976d8ef70f6a27570af5809c195574ab476ea113e447ab940aec34e34ab7f8

Contents?: true

Size: 823 Bytes

Versions: 1

Compression:

Stored size: 823 Bytes

Contents

module DOF
  module Responses
    class RequestResponse
      NO_ERROR_CODE = 200

      attr_reader :indicators
      attr_reader :response_code
      attr_reader :response_status
      attr_reader :total_indicators

      def initialize(response)
        parse_response(response)
      end

      def parse_response(response)
        @response_code = response["messageCode"]
        @response_status = response["response"]
        @total_indicators = response["TotalIndicadores"]
        @indicators = []

        build_indicator(response["ListaIndicadores"])
      end

      def build_indicator(data)
        data.each do |indicator|
          @indicators << Responses::IndicatorResponse.new(indicator)
        end
      end

      def successful?
        @response_code == NO_ERROR_CODE
      end
    end    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dof-1.0.0 lib/DOF/responses/request_response.rb