Sha256: 1d4dc3c354003fc61dd6da8a5af6cb7ac7cdd5a6edfad972d7bf5e9efa8473ba

Contents?: true

Size: 612 Bytes

Versions: 2

Compression:

Stored size: 612 Bytes

Contents

module Targetdata
  module Api
    class Pf
      include Auth
      include Requester

      def initialize cpf
        @cpf = cpf
      end
      
      def person
        response = get_person
        Entities::Person.new hash_person(response.body.to_s)
      end

      private
        def hash_person string_body
          parsed = JSON.parse(string_body)

          raise Targetdata::Errors::PersonNotFound unless person_found?(parsed)
          parsed["result"].first["pessoa"]["cadastral"]
        end
        
        def person_found? hash
          !hash["result"].empty?
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
targetdata-0.2.1 lib/targetdata/api/pf.rb
targetdata-0.2.0 lib/targetdata/api/pf.rb