Class: Harvest::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/harvest/base.rb

Direct Known Subclasses

Reports, TimeTracking

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
16
17
# File 'lib/harvest/base.rb', line 9

def initialize(options={})
  @domain = options[:domain] ||= Harvest.domain
  @email = options[:email] ||= Harvest.email
  @password = options[:password] ||= Harvest.password
  @use_ssl = options[:use_ssl] ||= Harvest.use_ssl
  
  self.class.base_uri "#{@domain}.harvestapp.com"
  self.class.basic_auth(@email, @password)
end

Instance Attribute Details

#domainObject

Returns the value of attribute domain.



7
8
9
# File 'lib/harvest/base.rb', line 7

def domain
  @domain
end

#emailObject

Returns the value of attribute email.



7
8
9
# File 'lib/harvest/base.rb', line 7

def email
  @email
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/harvest/base.rb', line 7

def password
  @password
end

#use_sslObject

Returns the value of attribute use_ssl.



7
8
9
# File 'lib/harvest/base.rb', line 7

def use_ssl
  @use_ssl
end

Instance Method Details

#rate_limit_statusObject



19
20
21
22
23
24
25
# File 'lib/harvest/base.rb', line 19

def rate_limit_status
  request = Mash.new(self.class.get('/account/rate_limit_status')).request
  %w(count time_frame_limit max_calls lockout_seconds).each do |key|
    request[key] = request[key].to_i
  end
  request
end