Class: Forecast::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/forecast/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ops = {}) ⇒ Base

def initialize(nil, access_token: nil)



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/forecast/base.rb', line 8

def initialize(ops={})
  @credentials = if ops[:forecast_account_id] and ops[:access_token]

    #
    # httparty stops the party (haha) if the access_token is not a String
    #
    string_ops = {
        forecast_account_id: ops[:forecast_account_id].to_s,
        access_token: ops[:access_token],
    }

    OAuthCredentials.new(string_ops)
  else
    fail 'You must provide either :forecast_account_id and :access_token'
  end
end

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



3
4
5
# File 'lib/forecast/base.rb', line 3

def credentials
  @credentials
end

#requestObject (readonly)

Returns the value of attribute request.



3
4
5
# File 'lib/forecast/base.rb', line 3

def request
  @request
end

Instance Method Details

#aggregatesObject

def milestones

@milestones ||= Forecast::API::Milestones.new(credentials)

end



107
108
109
# File 'lib/forecast/base.rb', line 107

def aggregates
  @aggregates ||= Forecast::API::Aggregates.new(credentials)
end

#assignmentsForecast::API::Projects

All API Actions surrounding Assignments

Examples

forecast.projects.all() # Returns all projects in the system
forecast.projects.all({start_date: '2016-11-28', end_date: '2017-01-01', state: 'active'})

forecast.projects.find(100) # Returns the project with id = 100

Returns:

See Also:



99
100
101
# File 'lib/forecast/base.rb', line 99

def assignments
  @assignments ||= Forecast::API::Assignments.new(credentials)
end

#projectsHarvest::API::Projects

All API Actions surrounding Projects

Examples

forecast.projects.all() # Returns all projects in the system

harvest.projects.find(100) # Returns the project with id = 100

project = Harvest::Project.new(:name => 'SuprGlu' :client_id => 10)
saved_project = harvest.projects.create(project) # returns a saved version of Harvest::Project

project = harvest.projects.find(205)
project.name = 'SuprSticky'
updated_project = harvest.projects.update(project) # returns an updated version of Harvest::Project

project = harvest.project.find(205)
harvest.projects.delete(project) # returns 205

project = harvest.projects.find(301)
deactivated_project = harvest.projects.deactivate(project) # returns an updated deactivated project
activated_project = harvest.projects.activate(project) # returns an updated activated project

project = harvest.projects.find(401)
harvest.projects.create_task(project, 'Bottling Glue') # creates and assigns a task to the project

Returns:

See Also:

  • Harvest::Behavior::Crud
  • Harvest::Behavior::Activatable


84
85
86
# File 'lib/forecast/base.rb', line 84

def projects
  @projects ||= Forecast::API::Projects.new(credentials)
end