Class: PrintNode::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/printnode/auth.rb

Overview

Handles which credentials we are using

Author:

  • Jake Torrance

  • PrintNode

Instance Method Summary collapse

Constructor Details

#initialize(value_a, value_b = nil) ⇒ Auth

Initalizes our credentials

With one, it is an API-Key.

Parameters:

  • value_a (String)

    two arguments : this will be an email address.

  • value_b (String) (defaults to: nil)

    The password relative to the email set in value_a.



11
12
13
14
15
16
17
18
# File 'lib/printnode/auth.rb', line 11

def initialize(value_a, value_b = nil)
  if value_b
    @email = value_a
    @password = value_b
  else
    @apikey = value_a
  end
end

Instance Method Details

#credentialsObject

Returns correctly formatted credentials for HTTP::Request.basic_auth

Returns:

An array of with our credentials.



23
24
25
# File 'lib/printnode/auth.rb', line 23

def credentials
  @apikey ? [@apikey, ''] : [@email, @password]
end