Class: Socialcast::CommandLine::Authenticate
- Inherits:
-
Object
- Object
- Socialcast::CommandLine::Authenticate
- Defined in:
- lib/socialcast/command_line/authenticate.rb
Instance Attribute Summary collapse
-
#authenticate_type ⇒ Object
Returns the value of attribute authenticate_type.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#options ⇒ Object
Returns the value of attribute options.
-
#params ⇒ Object
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(authenticate_type, options, params, headers = {}) ⇒ Authenticate
constructor
A new instance of Authenticate.
- #request ⇒ Object
Constructor Details
#initialize(authenticate_type, options, params, headers = {}) ⇒ Authenticate
Returns a new instance of Authenticate.
6 7 8 9 10 11 |
# File 'lib/socialcast/command_line/authenticate.rb', line 6 def initialize(authenticate_type, , params, headers = {}) self.authenticate_type = authenticate_type self. = self.params = params self.headers = headers end |
Instance Attribute Details
#authenticate_type ⇒ Object
Returns the value of attribute authenticate_type.
4 5 6 |
# File 'lib/socialcast/command_line/authenticate.rb', line 4 def authenticate_type @authenticate_type end |
#headers ⇒ Object
Returns the value of attribute headers.
4 5 6 |
# File 'lib/socialcast/command_line/authenticate.rb', line 4 def headers @headers end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/socialcast/command_line/authenticate.rb', line 4 def @options end |
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'lib/socialcast/command_line/authenticate.rb', line 4 def params @params end |
Class Method Details
.current_user ⇒ Object
13 14 15 |
# File 'lib/socialcast/command_line/authenticate.rb', line 13 def self.current_user @current_user ||= find_current_user end |
.find_current_user ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/socialcast/command_line/authenticate.rb', line 17 def self.find_current_user response = Socialcast::CommandLine.resource_for_path('/api/userinfo.json').get json_body = JSON.parse(response.body) if json_body['user'] json_body['user'] else raise "Unable to find the current user: #{response.body}" end end |
Instance Method Details
#request ⇒ Object
27 28 29 |
# File 'lib/socialcast/command_line/authenticate.rb', line 27 def request @request ||= send_request end |