Sha256: 23cea92515420ec10359ce51b5d9caa9d3732764475937a2008cde22e49e3ae3

Contents?: true

Size: 563 Bytes

Versions: 2

Compression:

Stored size: 563 Bytes

Contents

module RandomUserGenerator
  class Client
    HOST = 'http://api.randomuser.me'

    def request(params)
      response = connection.get(api_url, params)
      response.body['results'].map { |u| u['user'] || u }
    end

    private

    def connection
      Faraday.new(HOST, params: RandomUserGenerator.options) do |faraday|
        faraday.response :json

        faraday.use     FaradayMiddleware::FollowRedirects
        faraday.adapter Faraday.default_adapter
      end
    end

    def api_url
      "/#{RandomUserGenerator.api_version}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
random_user_generator-0.2.1 lib/random_user_generator/client.rb
random_user_generator-0.2.0 lib/random_user_generator/client.rb