Class: LearnWeb::Client

Inherits:
Object
  • Object
show all
Includes:
Connection, Environment, Fork, Lesson, PullRequest, Request, User, ValidateRepo
Defined in:
lib/learn_web/client.rb,
lib/learn_web/client/fork.rb,
lib/learn_web/client/user.rb,
lib/learn_web/client/lesson.rb,
lib/learn_web/client/request.rb,
lib/learn_web/client/user/me.rb,
lib/learn_web/client/connection.rb,
lib/learn_web/client/environment.rb,
lib/learn_web/client/fork/request.rb,
lib/learn_web/client/pull_request.rb,
lib/learn_web/client/validate_repo.rb,
lib/learn_web/client/lesson/next_lesson.rb,
lib/learn_web/client/validate_repo/slug.rb,
lib/learn_web/client/lesson/current_lesson.rb,
lib/learn_web/client/lesson/current_status.rb,
lib/learn_web/client/pull_request/response.rb,
lib/learn_web/client/environment/setup_list.rb

Defined Under Namespace

Modules: Connection, Environment, Fork, Lesson, PullRequest, Request, User, ValidateRepo

Constant Summary collapse

LEARN_URL =
'https://learn.co'
API_ROOT =
'/api/v1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Environment

#environment_setup_list, #environment_setup_list_endpoint

Methods included from User

#me, #me_endpoint

Methods included from Fork

#fork_endpoint, #fork_repo

Methods included from ValidateRepo

#validate_repo_slug, #validate_repo_slug_endpoint

Methods included from Lesson

#current_lesson, #current_lesson_endpoint, #current_status, #current_status_endpoint, #next_lesson, #next_lesson_endpoint

Methods included from PullRequest

#issue_pull_request, #pr_endpoint

Methods included from Connection

#get, #post

Constructor Details

#initialize(token:, silent_output: false) ⇒ Client

Returns a new instance of Client.



26
27
28
29
30
31
32
# File 'lib/learn_web/client.rb', line 26

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

Instance Attribute Details

#connObject (readonly)

Returns the value of attribute conn.



12
13
14
# File 'lib/learn_web/client.rb', line 12

def conn
  @conn
end

#silent_outputObject (readonly)

Returns the value of attribute silent_output.



12
13
14
# File 'lib/learn_web/client.rb', line 12

def silent_output
  @silent_output
end

#tokenObject (readonly)

Returns the value of attribute token.



12
13
14
# File 'lib/learn_web/client.rb', line 12

def token
  @token
end

Instance Method Details

#valid_token?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/learn_web/client.rb', line 34

def valid_token?
  !!me.data
end