Class: Coderbits::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/coderbits/client.rb

Constant Summary collapse

OPTIONS =

valid options

[:account, :callback]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeObject

Coderbits::Client.new



15
16
17
# File 'lib/coderbits/client.rb', line 15

def initialize
  @connection = Faraday.new url: "https://coderbits.com"
end

Instance Attribute Details

#connectionObject (readonly)

connection



10
11
12
# File 'lib/coderbits/client.rb', line 10

def connection
  @connection
end

Instance Method Details

#get(username, options = {}) ⇒ Object

Coderbits::Client.new.get username: ‘artemeff’



20
21
22
23
24
25
26
27
28
# File 'lib/coderbits/client.rb', line 20

def get username, options = {}
  response = @connection.get "/#{username}.json", safe(options)

  if options[:callback]
    response.body
  else
    MultiJson.load response.body, symbolize_keys: true
  end
end