Class: LearnWeb::Client

Inherits:
Object
  • Object
show all
Includes:
Connection, Environment, Event, Fork, Lesson, PullRequest, Request, SshKeys, 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/event.rb,
lib/learn_web/client/lesson.rb,
lib/learn_web/client/request.rb,
lib/learn_web/client/user/me.rb,
lib/learn_web/client/ssh_keys.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/ssh_keys/add.rb,
lib/learn_web/client/validate_repo.rb,
lib/learn_web/client/event/submission.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,
lib/learn_web/client/environment/verification.rb

Defined Under Namespace

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

Constant Summary collapse

LEARN_URL =
ENV.fetch('LEARN_CO_URL', 'https://learn.co').freeze
API_ROOT =
'/api/v1'

Constants included from Event

Event::IRONBROKER_URL

Instance Attribute Summary collapse

Attributes included from Event

#client

Instance Method Summary collapse

Methods included from SshKeys

#add_ssh_key, #add_ssh_key_endpoint

Methods included from Event

#submission_endpoint, #submit_event

Methods included from Environment

#environment_setup_list, #environment_setup_list_endpoint, #verification_endpoint, #verify_environment

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.



30
31
32
33
34
35
36
# File 'lib/learn_web/client.rb', line 30

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.



14
15
16
# File 'lib/learn_web/client.rb', line 14

def conn
  @conn
end

#silent_outputObject (readonly)

Returns the value of attribute silent_output.



14
15
16
# File 'lib/learn_web/client.rb', line 14

def silent_output
  @silent_output
end

#tokenObject (readonly)

Returns the value of attribute token.



14
15
16
# File 'lib/learn_web/client.rb', line 14

def token
  @token
end

Instance Method Details

#valid_token?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/learn_web/client.rb', line 38

def valid_token?
  !!me.data
end