require_relative 'search'
require_relative "../version"

module RailsIbm
  module Uprofile
    module Bluepages
      class Teams < Search
        def initialize(query)
          @response = HTTParty.get(uri(query: query), header: headers)
        end

        def results
          search_results
        end

        private

        def uri(query:)
          "#{RailsIbm::Uprofile::BLUEPAGES_V3_URI}/#{query}/teamResolved"
        end

        def headers
          {
            'Content-Type': 'application/json',
            accept: 'application/json'
          }
        end

        def search_type
          'team'
        end

        def search_results
          JSON.parse @response.body, symbolize_names: true
        end
      end
    end
  end
end
