Sha256: cefba0354cc7e7d05b0a4cf626080452675c012e8b10472cc01fc5911741eb26

Contents?: true

Size: 1.1 KB

Versions: 12

Compression:

Stored size: 1.1 KB

Contents

module LearnWeb
  class Client
    module User
      class Me
        attr_accessor :response, :id, :first_name, :last_name, :full_name,
                      :username, :email, :github_gravatar, :github_uid, :data,
                      :silent_output

        include LearnWeb::AttributePopulatable

        def initialize(response, silent_output: false)
          @response      = response
          @silent_output = silent_output

          parse!
        end

        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
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
learn-web-1.5.5 lib/learn_web/client/user/me.rb
learn-web-1.5.4 lib/learn_web/client/user/me.rb
learn-web-1.5.3 lib/learn_web/client/user/me.rb
learn-web-1.5.2 lib/learn_web/client/user/me.rb
learn-web-1.5.1 lib/learn_web/client/user/me.rb
learn-web-1.5.0 lib/learn_web/client/user/me.rb
learn-web-1.4.2 lib/learn_web/client/user/me.rb
learn-web-1.4.1 lib/learn_web/client/user/me.rb
learn-web-1.4.0 lib/learn_web/client/user/me.rb
learn-web-1.3.0 lib/learn_web/client/user/me.rb
learn-web-1.2.0 lib/learn_web/client/user/me.rb
learn-web-1.1.0 lib/learn_web/client/user/me.rb