Class: Harvest::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/harvest/credentials.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subdomain, username, password, ssl = true) ⇒ Credentials

Returns a new instance of Credentials.



5
6
7
# File 'lib/harvest/credentials.rb', line 5

def initialize(subdomain, username, password, ssl = true)
  @subdomain, @username, @password, @ssl = subdomain, username, password, ssl
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/harvest/credentials.rb', line 3

def password
  @password
end

#sslObject

Returns the value of attribute ssl.



3
4
5
# File 'lib/harvest/credentials.rb', line 3

def ssl
  @ssl
end

#subdomainObject

Returns the value of attribute subdomain.



3
4
5
# File 'lib/harvest/credentials.rb', line 3

def subdomain
  @subdomain
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/harvest/credentials.rb', line 3

def username
  @username
end

Instance Method Details

#basic_authObject



13
14
15
# File 'lib/harvest/credentials.rb', line 13

def basic_auth
  Base64.encode64("#{username}:#{password}").delete("\r\n")
end

#hostObject



17
18
19
# File 'lib/harvest/credentials.rb', line 17

def host
  "#{ssl ? "https" : "http"}://#{subdomain}.harvestapp.com"
end

#valid?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/harvest/credentials.rb', line 9

def valid?
  !subdomain.nil? && !username.nil? && !password.nil?
end