Sha256: 79b234599c42e209b3f699179e89b8f590771fc87c83162e1ae049465031fe4c

Contents?: true

Size: 519 Bytes

Versions: 1

Compression:

Stored size: 519 Bytes

Contents

require "net/http"
require "json"

module JazzHR
  class Client
    BASE_URI = "https://api.resumatorapi.com/v1".freeze

    def initialize(api_key:)
      @api_key = api_key
    end

    def get(path:)
      json_string = Net::HTTP.get(uri_for(path: path))
      response    = JSON.parse(json_string)

      raise Error.new(response["error"]) if response.is_a?(Hash) && response["error"]

      response
    end

    private

    def uri_for(path:)
      URI("#{BASE_URI}#{path}?apikey=#{@api_key}")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jazz_hr-0.1.2 lib/jazz_hr/client.rb