class LearnWeb::Client::User::Me

Attributes

data[RW]
email[RW]
first_name[RW]
full_name[RW]
github_gravatar[RW]
github_uid[RW]
id[RW]
last_name[RW]
response[RW]
silent_output[RW]
username[RW]

Public Class Methods

new(response, silent_output: false) click to toggle source
# File lib/learn_web/client/user/me.rb, line 11
def initialize(response, silent_output: false)
  @response      = response
  @silent_output = silent_output

  parse!
end

Public Instance Methods

parse!() click to toggle source
# File lib/learn_web/client/user/me.rb, line 18
def parse!
  if response.status == 200
    self.data = Oj.load(response.body, symbol_keys: true)

    populate_attributes!
  elsif silent_output == false
    case response.status
    when 401
      puts "It seems your OAuth token is incorrect. Please re-run config with: learn reset"
      exit 1
    when 500
      puts "Something went wrong. Please try again."
      exit 1
    else
      puts "Something went wrong. Please try again."
      exit 1
    end
  end

  self
end