Sha256: 9db652594d4497ec1e2e95533043e8808cfce8dd9b9b1976cd6f4436eb31f40f
Contents?: true
Size: 724 Bytes
Versions: 3
Compression:
Stored size: 724 Bytes
Contents
require 'faraday' module LearnWeb class Client attr_reader :token, :conn, :silent_output LEARN_URL = 'https://learn.co' API_ROOT = '/api/v1' def initialize(token:, silent_output: false) @token = token @silent_output = silent_output @conn = Faraday.new(url: LEARN_URL) do |faraday| faraday.adapter Faraday.default_adapter end end def me_endpoint "#{API_ROOT}/users/me" end def me response = @conn.get do |req| req.url me_endpoint req.headers['Authorization'] = "Bearer #{token}" end LearnWeb::Client::Me.new(response, silent_output: silent_output) end def valid_token? !!me.data end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
learn-web-0.0.12 | lib/learn_web/client.rb |
learn-web-0.0.11 | lib/learn_web/client.rb |
learn-web-0.0.1 | lib/learn_web/client.rb |