Class: Harvest::Credentials

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Credentials) initialize(subdomain, username, password, ssl = true)

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

- (Object) password

Returns the value of attribute password



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

def password
  @password
end

- (Object) ssl

Returns the value of attribute ssl



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

def ssl
  @ssl
end

- (Object) subdomain

Returns the value of attribute subdomain



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

def subdomain
  @subdomain
end

- (Object) username

Returns the value of attribute username



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

def username
  @username
end

Instance Method Details

- (Object) basic_auth



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

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

- (Object) host



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

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

- (Boolean) valid?

Returns:

  • (Boolean)


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

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