Class: Milkman::Authorizer

Inherits:
Object
  • Object
show all
Includes:
Utility
Defined in:
lib/milkman/authorizer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utility

#default_options, #encode, #format, #request_url, #sign

Constructor Details

#initialize(attributes) ⇒ Authorizer

Returns a new instance of Authorizer.



8
9
10
11
# File 'lib/milkman/authorizer.rb', line 8

def initialize(attributes)
  @shared_secret = attributes.delete(:shared_secret)
  @options       = attributes.merge! default_options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/milkman/authorizer.rb', line 6

def options
  @options
end

#shared_secretObject

Returns the value of attribute shared_secret.



6
7
8
# File 'lib/milkman/authorizer.rb', line 6

def shared_secret
  @shared_secret
end

Class Method Details

.authorize(options) ⇒ Object



13
14
15
# File 'lib/milkman/authorizer.rb', line 13

def self.authorize(options)
  new(options).authorize
end

Instance Method Details

#authorizeObject



17
18
19
20
# File 'lib/milkman/authorizer.rb', line 17

def authorize
  puts I18n.t("milkman.authorization.frob_message", url: frob_message_url)
  puts I18n.t("milkman.authorization.auth_token_message", username: response["rsp"]["auth"]["user"]["username"], api_key: options[:api_key], shared_secret: shared_secret, auth_token: response["rsp"]["auth"]["token"])
end