Class: Metalbird::Tumblr::Authentication

Inherits:
Object
  • Object
show all
Defined in:
lib/metalbird/tumblr/authentication.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Authentication

Returns a new instance of Authentication


8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/metalbird/tumblr/authentication.rb', line 8

def initialize(opts = {})
  validate_opts(opts)

  ::Tumblr.configure do |config|
    config.consumer_key = opts[:consumer_key]
    config.consumer_secret = opts[:consumer_secret]
    config.oauth_token = opts[:oauth_token]
    config.oauth_token_secret = opts[:oauth_token_secret]
  end

  @client = ::Tumblr::Client.new
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client


6
7
8
# File 'lib/metalbird/tumblr/authentication.rb', line 6

def client
  @client
end

Instance Method Details

#validate_opts(opts) ⇒ Object


21
22
23
24
25
26
27
28
29
# File 'lib/metalbird/tumblr/authentication.rb', line 21

def validate_opts(opts)
  if !opts[:consumer_key] ||
     !opts[:consumer_secret] ||
     !opts[:oauth_token] ||
     !opts[:oauth_token_secret]
  
    fail ArgumentError
  end
end